These sample start session scripts illustrate how to write environment variables to a file, test the timeout functionality, and test a non-zero exit code.
The following sample Visual Basic script writes all the environment variables provided to the script into a file. You can use this sample script to see example data in your own environment. You might save this script as C:\sample.vbs.
Option Explicit Dim WshShell, FSO, outFile, strOutputFile, objUserEnv, strEnv strOutputFile = "c:\setvars.txt" Set FSO = CreateObject("Scripting.fileSystemObject") Set outFile = FSO.CreateTextFile(strOutputFile, TRUE) outFile.WriteLine("Script was called at (" & Now & ")") Set WshShell = CreateObject( "WScript.Shell" ) Set objUserEnv = WshShell.Environment("PROCESS") For Each strEnv In objUserEnv outFile.WriteLine(strEnv) Next outFile.Close
The following sample script tests the timeout functionality.
Option Explicit WScript.Sleep 60000
The following sample script tests a non-zero exit code.
Option Explicit WScript.Quit 2