Skrypton.Windows.NetFx 1.7.78

There is a newer version of this package available.
See the version list below for details.
dotnet add package Skrypton.Windows.NetFx --version 1.7.78
                    
NuGet\Install-Package Skrypton.Windows.NetFx -Version 1.7.78
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Skrypton.Windows.NetFx" Version="1.7.78" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Skrypton.Windows.NetFx" Version="1.7.78" />
                    
Directory.Packages.props
<PackageReference Include="Skrypton.Windows.NetFx" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Skrypton.Windows.NetFx --version 1.7.78
                    
#r "nuget: Skrypton.Windows.NetFx, 1.7.78"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Skrypton.Windows.NetFx@1.7.78
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Skrypton.Windows.NetFx&version=1.7.78
                    
Install as a Cake Addin
#tool nuget:?package=Skrypton.Windows.NetFx&version=1.7.78
                    
Install as a Cake Tool

Skrypton

Seamlessly migrate legacy VBScript to C# — translated into readable source and executed with identical runtime behavior.

Build Status Test Status Code coverage

Artifacts

Name nuget.org GitHub Packages
Skrypton (+ the command line tools in tools) NuGet GitHub Packages
Skrypton.Windows (.NET 10, Windows) NuGet GitHub Packages
Skrypton.Windows.NetFx (.NET Framework 4.8) NuGet GitHub Packages

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, and Nothing are 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 through Err.
  • Late binding and default members — obj, obj(0), and obj.Value can 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 Error trapping, deterministic Class_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/IDispatch binding.
  • ScriptControl emulation (AddCode / AddObject / ExecuteStatement) and Parse(...) for structural analysis.

In progress

  • Several ScriptControl members (Eval, Run, Reset, Modules, CodeObject, UseSafeSubset) are NotImplementedException stubs.
  • CreateObject provides 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.txt for 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 Compatible and additional computed target framework versions.
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 29 11/20/2026
1.7.88 64 11/20/2026
1.7.78 115 11/13/2026
1.7.75 87 11/12/2026
1.7.72 94 11/12/2026
1.7.70 87 11/12/2026
1.7.63 90 11/12/2026
1.7.60 87 11/12/2026
1.7.51 86 11/12/2026
1.7.46 90 11/12/2026
1.7.20 98 11/11/2026
1.7.13 89 11/11/2026
1.7.8 86 11/11/2026
1.7.6 86 11/11/2026
1.7.4 84 11/11/2026
1.7.2 83 11/11/2026