NONEXECUTABLE: To obtain the executable file, download the Zip file from the opening page of the article. Listing 1: Demo.vbs ' * ' demo.vbs ' * ' Declaration and Initialization Section ' * Rem *** Script Directives *** Option Explicit On Error Resume Next Rem *** Variable Declarations *** Dim objFileSystem, objShell, objLogFile, objTempFile Dim arrStrings, intReturnCode Dim strBuffer, strLogFile, strTempFile Rem *** Constant Definitions *** Const OpenFileForReading = 1 Rem *** Variable Initialization *** intReturnCode = 0 strBuffer = "" strLogFile = "c:\" & Split(WScript.ScriptName, ".")(0) & ".log" strTempFile = "c:\temp.txt" BEGIN CALLOUT A arrStrings = Array("abcdefghijklmnopqrstuvwxyz", _ "ABCDEFGHIJKLMNOPQRSTUVWXYZ", _ "the quick brown fox jumps over the lazy dogs back") END CALLOUT A ' Script Body Section ' * BEGIN CALLOUT B ' Using If-Then-End If to demonstrate the On Error Resume Next statement. If Err.Number Then WScript.Echo "Bob's Friendly Error Message" & vbNewLine & _ "Error Number: " & Err.Number & vbNewLine & _ "Error Description: " & Err.Description Err.Clear End If END CALLOUT B ' Create scripting runtime FileSystemObject. ' Create TextStream object for script's log file. ' Write starting line to log file. Set objFileSystem = CreateObject("Scripting.FileSystemObject") Set objLogFile = objFileSystem.CreateTextFile(strLogFile, TRUE) objLogFile.WriteLine(Now & ":" & vbTab & WScript.ScriptFullName & " Started.") ' Create WSH Shell object. ' Run external command redirecting commands output to temporary file. ' Check for error condition and write appropriate message to log file. Set objShell = WScript.CreateObject("WScript.Shell") intReturnCode = objShell.Run("cmd /C ipconfig.exe >" & strTempFile, 0, TRUE) If Err.Number Then objLogFile.WriteLine(Now & ":" & vbTab & Err.Number & ": " & Err.Description) Err.Clear Else objLogFile.WriteLine(Now & ":" & vbTab & "Run completed successfully.") End If ' Create TextStream object to read in c:\temp.txt file, which the run ' command created. ' Read entire file into buffer using the TextStream objects ReadAll method. ' Check for error and write appropriate message to log file. ' Close TextStream object. Set objTempFile = objFileSystem.OpenTextFile(strTempFile, OpenFileForReading) strBuffer = objTempFile.ReadAll If Err.Number Then objLogFile.WriteLine(Now & ":" & vbTab & Err.Number & ": " & Err.Description) Err.Clear Else objLogFile.WriteLine(Now & ":" & vbTab & "Open and read " & strTempFile & _ " completed successfully.") End If objTempFile.Close ' Display the buffer contents that are the redirected result of the run ' command. WScript.Echo strBuffer ' Delete c:\temp.txt file. ' Check for error and write appropriate message to log file. objFileSystem.DeleteFile(strTempFile) If Err.Number Then objLogFile.WriteLine(Now & ":" & vbTab & Err.Number & ": " & Err.Description) Err.Clear Else objLogFile.WriteLine(Now & ":" & vbTab & "Delete " & strTempFile & _ " completed successfully.") End If ' Write closing line to log file and close log file. objLogFile.WriteLine(Now & ":" & vbTab & WScript.ScriptFullName & " Finished.") objLogFile.Close ' Create TextStream object to read in log file. ' Read entire file into buffer using the TextStream objects ReadAll method. ' Close TextStream object. Set objLogFile = objFileSystem.OpenTextFile(strLogFile, OpenFileForReading) strBuffer = objLogFile.ReadAll objLogFile.Close ' Display the buffer's content, which is the log file in this case. WScript.Echo strBuffer ' Delete the log file, release object references, and exit script. objFileSystem.DeleteFile(strLogFile) Set objShell = Nothing Set objFileSystem = Nothing WScript.Quit(0) ' * ' * demo.vbs end