Perhaps you've read my four part series entitled, Visual Basic 101. In that series I explained how to build a specialized SAM bandwidth calculator. Granted, that series was long and in-depth, but I think it was worth it. However, I am also aware that most sysadmins don't have the luxury of a lot of free time. A four part series on VB may have been overkill, especially if you're sysadmin putting out fires constantly. Enter VBScript. Think of it as Visual Basic without the pesky API. This will be a hit and run lesson/example of how to have a VBScript start another program.

Wrapping VBScript around an executable file.

The following example demonstrates how to write a simple VBScript to open notepad.exe:

1. Open Notepad and paste the following code into a new document:


    Set WshShell = WScript.CreateObject("WScript.Shell")
    Dim exeName
    Dim statusCode
    exeName = "%windir%\notepad"
    statusCode = WshShell.Run (exeName, 1, true)
    MsgBox("End of Program")


2. Save the file as Example.vbs (manually change the extension to .vbs)

3. Double-click Example.vbs to run the program which launches Notepad.exe, then shows a message box upon closing.


Note: To open a program other than Notepad, change the highlighted section above to the path and program you want to execute, for example, "C:\Program Files\Mozilla Firefox\firefox.exe"

SolarWinds SAM has a Windows script monitor that can handle various programming languages, including VBScript. It may behoove you to become familiar with at least one.