How to Use DotNetWrapper.vbs
To use DotNetWrapper.vbs, you must have Windows Script Host (WSH) 5.6 and .NET Framework 1.1 or later installed on the machine on which you plan to run it. To determine which version of the .NET Framework you have on your machine, you can look in the %systemroot%\Microsoft.NET\ Framework folder. Each version of the .NET Framework appears in a subfolder. I wrote the script to work with version 1.1.4322. If you have a later version, you need to change the information on the following line in DotNetWrapper.vbs to match your version:
dotNetVersion = "v1.1.4322"
Another change you might need to make concerns the code
System.Threading.Thread.Sleep
(1000)
This code, which inserts a 1-second pause, is used twice in DotNetWrapper.vbs. The first pause occurs between the closing of the temporary file and the execution of the script. The second pause occurs between the execution of the script and the deletion of the script. It might be necessary (although unlikely) to increase the length of the pauses based on the size of the script you're protecting. A 1-second pause works fine for the largest scripts (about 500 lines, or 14KB) I run with DotNetWrapper.vbs. If you do need to change it, simply change the 1000 value to, say, 2000, which would create a 2-second pause.
Other than these two possible changes, DotNetWrapper.vbs requires no modifications. You can download DotNetWrapper.vbs from the Windows Scripting Solutions Web site.
To run DotNetWrapper.vbs, use the syntax
DotNetWrapper.vbs
Script_File Script_Type Script_Engine
Output_File [Icon_File]
The Script_File argument specifies the pathname of the script you want to protect. If this argument (or any of the other arguments) includes spaces, enclose it in quotes (e.g., "C:\My Scripts\ myscript.vbs").
The Script_Type argument specifies the extension (e.g., .vbs) of the script you want to protect. Be sure to include the period (.) in the extension.
The Script_Engine argument specifies the scripting engine with which to launch the script you're protecting. Scripting engines that are in the computer's system path can be called by specifying the program name (e.g., specifying cscript.exe for CScript or wscript.exe for WScript). Otherwise, you need to specify the full pathname to the scripting engine. If you want the Windows command interpreter (cmd.exe) to run the script, specify
"%COMSPEC% /k". The /k option leaves the command-shell window visible for displaying information. If you want the script to run in a hidden window, you can specify "%COMSPEC% /c" instead.
The Output_File argument specifies the name you want to assign to the executable that the .NET Framework creates. Specify the full pathname (e.g., "C:\Programs\myscript.exe").
Unlike the other four arguments, the Icon_File argument is optional. If you specify a full pathname (C:\ Icons\mypicture.ico), an icon will be created for the .NET executable.
Protect Your Scripts
After you've written a wonderful script, stop and consider whether you need to protect it before you send it out into the world. If that script needs some protection, DotNetWrapper.vbs might be just what you need.