WSH Basics

Lets take a quick look at some example code in WSH, lets start with launching Internet Explorer :

WshShell.Run iexplore.exe

Displaying a message to the user is also very simple :

WScript.Echo "Hello World"

Working with files is also relatively simple, lets create a file and write some text into it :

Dim fso ' define an object that we can use to connect to the client file system
Dim tf ' define an handle for our text file
' create the connection to the File System
Set fso = CreateObject("Scripting.FileSystemObject")
' create a handle for our text file, we are going to open the file, overwriting it if it exists, creating it if not
Set tf = fso.OpenTextFile("C:\myfile.txt", 2, True)
' write some text
tf.Write("Hello World")
tf.Write(" Goodby Cruel World")
' close the file

Interacting with the local registry is also relatively simple, in the following sample we are going to read a value into a variable called my_charset :

Dim my_charset ' define a var to hold our Char Set
Dim key ' define the Registry key to get
Dim Sh ' define our Shell object, through which we get into the Registry
' Create a connection to the client
Set Sh = CreateObject("WScript.Shell")
' set the location of the Registry key we are looking for
' get the value and assign it to our variable

As you can see it is all relatively simple, in this section of my site I've included some worked examples and some more detail about the WSH, I also recommend looking on the Microsoft MSDN site and searching the Internet to find more specific information if you require it.