Distributing a VBScript Application

How to Create a Distribution Package with IExpress

© Mark Alexander Bain

Jan 16, 2009
Creating a VBScript Distribution Package, Mark Alexander Bain
VBScript is very easy to distribute. However, to protect the code the programmer may wish to consider creating an installation package with IExpress

When it comes to creating Microsoft Windows applications VBScript is always a good choice. That's because of two reasons:

  1. VBScript is installed on every Microsoft Windows computer making any code easy to distribute (it's just a matter of copying a VBScript vbs file from one computer to another)
  2. VBScript does not need any special software for the programmer to be able to develop applications - all they need is a text editor (such as notepad, or notepad++)

However, this ease of development can also cause problems for the application programmer. If the programmer only needs notepad to develop the application then that's all that a user needs to change it. Once the developer passes their application to a user then they lose all control over any changes that may be made to it. If this is likely to be a problem then the programmer may want to consider using a distribution package to protect the code.

Microsoft Windows actually comes with it's own distribution package - IExpress (short for Internet Express). This can be used to package and to run an application without the user being aware of any of the technicalities of the application. However, there is one minor problem to overcome - IExpress does not automatically recognize a vbs file as an executable.

Preparing a VBScript Application for Distribution

A VBScript Application user normally runs the application in one of two ways:

  • by double clicking on the .vbs file
  • by running the file from the command line using CScript:
    cscript <VBScript filename>.vbs

It's this ability to run the vbs file by using CScript that allows the programmer to create a bat file, and it's this bat file that will be run by IExpress. Of course the first step is to create the vbs file itself, for example c:\vbscript\hello.vbs:

dim text : text = "Hello World"
msgbox text

The bat file to run this (for example c:\vbscript\hello.bat) would contain:

cscript hello.vbs

With that the programmer has everything that they need to create a distribution package.

Creating the Distribution Package

The first step to creating the distribution package is to run c:\windows\system32\iexpress.exe. This will start the IExpress wizard which consists of a number of screens that help the programmer to create the package:

  1. Welcome to IExpress 2.0 - Select 'Create new Self Extraction Directive file'
  2. Package purpose - Select 'Extract files and run an installation command'
  3. Package Title - The programmer must create an appropriate name for their application
  4. Confirmation Prompt - The user will want to run the application and nothing else so select 'No prompt'
  5. License agreement - Select 'Do not display a license'
  6. Packaged Files - The programmer can now include any required files. In this example that is:
    • hello.bat
    • hello.com
  7. Install Program to Launch - When the user runs the package it can automatically launch the application and so, of course, the programmer must select:
    • hello.bat
  8. Show window - The user will wish to see the VBScript application only and so the programmer should select 'Hidden'
  9. Finished message - Select 'No message'
  10. Package Name and Options - The programmer now has the chance to set up a few final options:
    • the target path and file name for the package
    • to 'Hide the File extracting Progress Animation from User'
  11. Configure restart - The package can restart the computer if required, but obviously that is not necessary in this case
  12. Save Self Extraction Directive - The directive (all the options selected so far) can be saved if the programmer is likely to be doing this again
  13. Create package - Finally the wizard will create the package itself

At the end of the process a new distribution package will have been created, and this can be passed on to any users (for example by uploading the package on to a web site or network folder). The users will then be able to run the application without even knowing anything at all about VBScript.


The copyright of the article Distributing a VBScript Application in Windows Programming is owned by Mark Alexander Bain. Permission to republish Distributing a VBScript Application in print or online must be granted by the author in writing.


Creating a VBScript Distribution Package, Mark Alexander Bain
       


Post this Article to facebook Add this Article to del.icio.us! Digg this Article furl this Article Add this Article to Reddit Add this Article to Technorati Add this Article to Newsvine Add this Article to Windows Live Add this Article to Yahoo Add this Article to StumbleUpon Add this Article to BlinkLists Add this Article to Spurl Add this Article to Google Add this Article to Ask Add this Article to Squidoo