VBScript Sample Code Treasure Chest Print E-mail
Written by Darwin Sanoy   
Friday, September 3, 2010 4:25pm
Google is the world's largest sample code repository for any programming or scripting language - but some gems escape the search results page!  Here is the location of a treasure chest of slick VBScript code.

I think one of the reasons this particular page isn't found is that the code is contained in zip files and is not in the text of the webpages themselves.

The web link I am going to give you here is an incredibly long web page packed with a lot of information, so I want to give some su.mmary highlights you will want to look for.

Many of the scripts show multiple ways to do the same or similar things in VBScript - very helpful since there are frequently reasons why a specific method will not work for given script you are writing.

This sample code uses a lot of VBScript class objects.  When you use them to create a VBScript object, they allow a rich set of functionality to be used against whatever they were made to manage.

Include Statement for VBScript
Many languages have an "include" statement that will load code from a separate file and let it be used in the current context - VBScript does not have this functionality.  However, ClassExtExe.zip contains ClsDemo.vbs - this script shows a method for loading additional VBScript code from a file. Check out the sub "AddClass".  You could rename this sub IncludeScript or something similar.

VBScript Registry and INI Operations
With the introduction of Windows 95 Microsoft depreciated INI files and has had scant support for them in their programming and scripting languages. Even the venerable Powershell requires you to cobble something together yourself.  claspak.zip contains vbscript class objects for the registry and INI files.  Also wmireg.zip contains a class for accessing the registry using local WMI - since WMI registry access has functionality such as enumeration, this class is more capable - but you don't even have to worry about how to set WMI up - it is all handled internally by the object.

Dialogs and Progress Bars
VBScript (and most scripting languages) has limited UI capabilities.  Check out iebar.zip and msgb.zip for various ways of create faux message boxes and dialogs in IE.  Note that under IE 7 and later these methods do not work as well.

Browsing for Files, Folders and Other Dialogs
ShellApp.zip contains some great code for showing how to prompt for folder locations as well as open other special Windows dialogs such as search and shutdown.  

Retrieving Windows Special Folders
As you have to support Windows 7 and XP at the same time, scripts that can accurately find all the new Windows 7 file locations will be very useful.   Among the scripts in wshell.zip is one that demonstrates multiple ways to find many of the Special folders on Windows.

That's the highlights of the many script samples you will find at this JSWare page.

Add comment

Security code