Skrypton.Windows
1.7.46
See the version list below for details.
dotnet add package Skrypton.Windows --version 1.7.46
NuGet\Install-Package Skrypton.Windows -Version 1.7.46
<PackageReference Include="Skrypton.Windows" Version="1.7.46" />
<PackageVersion Include="Skrypton.Windows" Version="1.7.46" />
<PackageReference Include="Skrypton.Windows" />
paket add Skrypton.Windows --version 1.7.46
#r "nuget: Skrypton.Windows, 1.7.46"
#:package Skrypton.Windows@1.7.46
#addin nuget:?package=Skrypton.Windows&version=1.7.46
#tool nuget:?package=Skrypton.Windows&version=1.7.46
Skrypton
Seamlessly migrate legacy VBScript to C# — translated into readable source and executed with identical runtime behavior.
Artifacts
| Name | nuget.org | GitHub Packages |
|---|---|---|
Skrypton (+ the command line tools in tools) |
||
| Skrypton.Windows (.NET 10, Windows) | ||
| Skrypton.Windows.NetFx (.NET Framework 4.8) |
Background
VBScript is being retired. Microsoft has deprecated it and is removing it from Windows, which puts every classic ASP page, .vbs automation script, and MSScriptControl-hosted rules engine on a countdown. The obvious answer — "just rewrite it in C#" — is a trap, because VBScript's behavior is not the syntax on the page:
- Variants —
Empty,Null, andNothingare three distinct kinds of "no value", each with its own comparison and coercion rules. - ByRef by default — every argument is passed by reference unless declared
ByVal. On Error Resume Next— errors don't halt execution; they are swallowed and inspected later throughErr.- Late binding and default members —
obj,obj(0), andobj.Valuecan all resolve to the same call. - Literal-driven coercion — a comparison can behave differently depending on which side the literal sits on.
A hand rewrite silently changes these semantics, and the regressions surface in production. Skrypton exists to remove that risk: it translates VBScript to readable C# and ships a runtime support library that reproduces VBScript's semantics at execution time, so the generated code doesn't just look like the original — it behaves like it.
VBScript source ──▶ Skrypton ──▶ C# source ──▶ (Roslyn) ──▶ .NET assembly
│
└── references Skrypton.RuntimeSupport (the `_` compat layer)
Getting started
Skrypton targets netstandard2.0 and is built with the .NET 10 SDK (pinned in global.json). Install the NuGet package:
dotnet add package Skrypton
or build from source:
git clone https://github.com/benhauman/Skrypton.git
dotnet build Skrypton.slnx -c Release
There are three entry points, depending on how far you want to go:
| Goal | API |
|---|---|
| Inspect the C# a script becomes | DefaultTranslator.TranslateExecutable(...) / TranslateWithoutScaffolding(...) |
| Analyse a script's structure without translating | DefaultTranslator.Parse(...) → an ICodeBlock tree |
| Translate and run VBScript like the old COM engine | ScriptControlSupport.ScriptControlClass |
Translating a script
Given a small VBScript program:
Dim name
name = "World"
WScript.Echo "Hello, " & name
translate it to C# with DefaultTranslator. Any names that exist in the host environment (WScript, Request, Response, Session, …) are declared as external dependencies so the translator doesn't warn about them:
using System.Globalization;
using Skrypton.CSharpWriter;
using Skrypton.CSharpWriter.Lists;
string csharp = DefaultTranslator.TranslateWithoutScaffolding(
culture: CultureInfo.CurrentCulture,
scriptContent: vbscript,
externalDependencies: NonNullImmutableList<string>.Empty.Add("WScript"),
externalMemberMethods: [],
suppressions: []);
The generated program has a fixed shape. Outer-scope statements go into a Runner, global variables and functions into GlobalReferences, host objects into EnvironmentReferences, and each VBScript Class becomes a C# class:
namespace TranslatedProgram
{
public sealed class Runner : RunnerBaseT<EnvironmentReferences, GlobalReferences>
{
protected override void Go(...) { /* outer-scope statements */ }
}
public sealed class GlobalReferences : ... { /* global vars + functions */ }
public sealed class EnvironmentReferences : ... { /* WScript, Request, ... */ }
// ...translated VBScript classes
}
Every operation routes through the runtime support layer (referenced as _): _.ADD(a, b), _.CALL(...), _.IF(...), _.HANDLEERROR(token, ...). That layer is where Variant rules, error trapping, late binding, CreateObject, and the built-in functions actually live — which is why the translated code reproduces VBScript behavior rather than merely resembling it.
Compiling the generated code
The translated C# is ordinary source. Compile it with Roslyn (or dotnet build) against the Skrypton runtime assembly, which supplies RunnerBase, GlobalReferencesBase, EnvironmentReferencesBase, and the IProvideVBScriptCompatFunctionalityToIndividualRequests compat layer. The ScriptControl path (below) does exactly this in-process.
Hosting
ScriptControlSupport.ScriptControlClass is a managed drop-in for the MSScriptControl.ScriptControl COM component that legacy applications used to host VBScript. Instead of the retired scripting engine, it translates the added code to C#, compiles it with Roslyn, and executes it:
var control = new ScriptControlSupport.ScriptControlClass { Language = "VBScript" };
control.AddObject("Host", myHostObject, addMembers: true); // wired in as an EnvironmentReference
control.AddCode(vbscript);
control.ExecuteStatement("DoTheThing"); // translate → compile → run
Running .vbs files from the command line
Two command line tools run VBScript files like cscript.exe - the script is translated to C#, compiled and run, WScript.Echo writes to the console, WScript.Arguments are the script arguments and WScript.Quit sets the exit code:
| Tool | Runtime | In the Skrypton package |
|---|---|---|
Skrypton.Windows.Cli.exe |
.NET 10 (Windows x64) | tools\Skrypton.Windows.Cli\ |
Skrypton.Windows.NetFx.Cli.exe |
.NET Framework 4.8 | tools\Skrypton.Windows.NetFx.Cli\ |
Skrypton.Windows.Cli.exe /help
Skrypton.Windows.Cli.exe report.vbs arg1 arg2
Skrypton.Windows.Cli.exe /culture:de-DE import.vbs C:\data\input.csv
Skrypton.Windows.Cli.exe /translate report.vbs > report.cs
CreateObject provides Scripting.FileSystemObject, Scripting.Dictionary, VBScript.RegExp, WScript.Shell, Shell.Application, ADODB, MSXML, WMI (winmgmts:), Word.Application and Excel.Application (.docx / .xlsx without Office), Outlook.Application, InternetExplorer.Application and htmlfile. The tools use the host services of Windows (Skrypton.Windows / Skrypton.Windows.NetFx): processes, the clipboard, MsgBox / InputBox dialogs, ADO through the OLE DB providers and Outlook through its COM automation. Runtime errors are reported as cscript reports them (script.vbs(3, 1) Microsoft VBScript runtime error: Type mismatch).
The demo scripts in samples/Windows (Outlook, Edge, ADO, Excel, Word, processes, files) show the use cases; their output is compared with the output of cscript.exe (with the real Office applications) in the tests of both tools.
Running scripts from a Windows application
On Windows, WindowsRuntimeHost.CreateDefault() (Skrypton.Windows / Skrypton.Windows.NetFx) provides the host services that the built-in components use, and ScriptonScriptRunner runs whole scripts with a WScript object, as the command line tools do:
var runner = new ScriptonScriptRunner(WindowsRuntimeHost.CreateDefault(), Console.Out, Console.Error, Console.In, CultureInfo.CurrentCulture);
int exitCode = runner.RunFile("report.vbs", args);
Project status
Skrypton works for the translate-and-run path but is still under active construction. Honest status:
Working today
- Full VBScript front-end covering
If/ElseIf/Else,For/For Each,Do/While/Loop/Wend,Select Case,Class,Function/Sub/Property,Dim/ReDim Preserve/Const/Public/Private,Erase,Exit,On Error Resume Next/Goto 0,Randomize,With,Option Explicit. - C# code generation including the hard parts: ByRef aliasing (VBScript ByRef ↔ C# lambdas),
On Errortrapping, deterministicClass_Terminate→IDisposable, and literal-driven comparison coercion. - Runtime support library: Variant semantics, the full operator set, 100+ built-in functions, the VBScript error hierarchy, and late/
IDispatchbinding. ScriptControlemulation (AddCode/AddObject/ExecuteStatement) andParse(...)for structural analysis.
In progress
- Several
ScriptControlmembers (Eval,Run,Reset,Modules,CodeObject,UseSafeSubset) areNotImplementedExceptionstubs. CreateObjectprovides managed implementations of the common COM components (see above); for other ProgIDs register managed factories.- Internals still carry the upstream
VBScriptTranslator.*namespaces (see Credits).
Not there yet
- No migration cookbook (see
todos.txtfor the running list of edge cases).
Syntax reference
How Skrypton maps the front-end pipeline and the language it accepts.
Pipeline
raw string
→ StringBreaker split out strings, comments, date literals
→ TokenBreaker break the rest into atoms (names, operators, braces…)
→ OperatorCombiner fold < + = into <= , collapse -- ++ runs
→ NumberRebuilder reassemble numeric literals ( .1 → 0.1 ), resolve .
→ CodeBlockHandler build an ICodeBlock tree (If / For / Class / Sub / …)
→ ExpressionGenerator (on demand) precedence-correct expression trees
Supported constructs
| Category | Constructs |
|---|---|
| Conditionals | If / ElseIf / Else, Select Case |
| Loops | For…Next, For Each, Do…Loop, While…Wend |
| Declarations | Dim, ReDim [Preserve], Const, Public, Private |
| Procedures | Function, Sub, Property Get/Let/Set (with Default) |
| Types | Class (incl. Class_Initialize / Class_Terminate) |
| Error handling | On Error Resume Next, On Error Goto 0, Err.Raise, Err.Clear |
| Statements | Set / Let, Call, Erase, Exit, Randomize, With, Option Explicit |
Built-in functions
100+ VBScript intrinsics, including type conversion (CInt, CLng, CDbl, CStr, CDate, CBool, Int, Fix), strings (Len, Mid, Left, Right, InStr, Replace, Split, Join, Trim, LCase, UCase), math (Abs, Round, Sqr, Rnd, Sgn), type tests (IsNull, IsEmpty, IsNumeric, IsObject, IsArray, TypeName, VarType), arrays (Array, LBound, UBound), date/time (Now, DateAdd, DateDiff, DatePart, FormatDateTime), and object/eval (CreateObject, GetObject, Eval, Execute, GetRef).
Project layout
src/Skrypton/
├── LegacyParser/ front-end stage 1: tokenizing + block parsing
├── StageTwoParser/ front-end stage 2: number/operator combining + expressions
├── CSharpWriter/ back-end: ICodeBlock tree → C# source
│ └── CodeTranslation/ scope tracking, block & statement translators
├── RuntimeSupport/ the `_` compat layer the generated code runs against
└── ScriptControlSupport/ managed MSScriptControl.ScriptControl replacement
src/Skrypton.Windows/ Windows host services, WScript, script runner (.NET 10)
src/Skrypton.Windows.NetFx/ the same for the .NET Framework 4.8
src/Skrypton.Windows.Cli/ command line tool (.NET 10)
src/Skrypton.Windows.NetFx.Cli/ command line tool (.NET Framework 4.8)
samples/Windows/ demo scripts (with the output of cscript)
Credits
Skrypton builds on the VBScriptTranslator project by Dan Roberts, which pioneered the parser, translator, and runtime-compat approach used here. It is reworked and extended under the same Apache-2.0 license.
License
Apache License 2.0 — © BENLENA.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-windows7.0 is compatible. |
-
net10.0-windows7.0
- Microsoft.CodeAnalysis.Analyzers (>= 5.3.0)
- Microsoft.CodeAnalysis.CSharp (>= 5.6.0)
- Skrypton (>= 1.7.46)
- System.Data.OleDb (>= 10.0.15)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.7.90 | 19 | 11/20/2026 |
| 1.7.88 | 43 | 11/20/2026 |
| 1.7.78 | 89 | 11/13/2026 |
| 1.7.75 | 92 | 11/12/2026 |
| 1.7.72 | 89 | 11/12/2026 |
| 1.7.70 | 86 | 11/12/2026 |
| 1.7.63 | 88 | 11/12/2026 |
| 1.7.60 | 86 | 11/12/2026 |
| 1.7.51 | 84 | 11/12/2026 |
| 1.7.46 | 90 | 11/12/2026 |
| 1.7.20 | 93 | 11/11/2026 |
| 1.7.13 | 90 | 11/11/2026 |
| 1.7.8 | 90 | 11/11/2026 |
| 1.7.6 | 88 | 11/11/2026 |
| 1.7.4 | 88 | 11/11/2026 |
| 1.7.2 | 82 | 11/11/2026 |