Tech Note 23: Converting VBScript programs to EXE files

October 14, 2005

© 2016 NS BASIC Corporation. All rights reserved.


It's easy to turn those VBScript files (.vbs) into executables (.exe) using NS Basic/Desktop. Once converted, they cannot be modified or viewed by other users and can be used more easily in other procedures. You may redistribute the executables you create freely: they will run on any Windows XP or Windows 2000 system.

You can jazz them up if you like, using NS Basic/Desktop's buttons, labels and input objects to make an easy to use interface.

Here's how. Let's start with a simple VBSscript. Open it in NotePad:

Copy the text onto the clipboard.

Start a new NS Basic/Desktop project. Select 'Formless'. You'll get a blank code window. Paste your existing VBScript code into the window and save the project as 'Environment'.

Now, click on F5. Environment.exe will be created. Running it gives this output:

While this works just as well as the original VBScript, there's lots you can do to improve things from here. You could format the information nicely in a window, create your own icon on the app, ask the user if he wants to do anything else, etc. Since it's an executable, your users will not be able to view the code or modify it in any way.





To put your code into a program that has a nice window as its front end, choose "Standard" when you start the new project. A blank Design Screen will show up. Double click it to bring up the Code Window, then paste your existing code at the top of the Code Window. You can then add buttons, fields or any other NS Basic object to the form, and call subroutines that are in the code you pasted in.

Note: NS Basic/Desktop does not use the Windows Scripting Host. If you use WScript.* operations in your program, you'll need to modify your code. Here are a few examples:

VBScript NS Basic/Desktop
WScript.Arguments GetCommandLine
WScript.CreateObject(...) CreateObject(...)
WScript.Echo ... Print or MsgBox ...
WScript.Quit Bye

Another way to use functions in the Windows Scripting Host is to add it to your project as an object. Simply do

   Set WSH = CreateObject("WScript.Shell")