Sub Main() Dim blnTrace ? Display extra output (for debugging purposes) Dim strComputerName ? String containing the computer name Dim strJobName ? String containing the job name Dim strStartIn ? «Start-in» directory for the program Dim strCommand ? String containing command line Dim lngExitCode ? Exit code for the command ? Abort if not using cscript.exe. If ScriptHost() <> «cscript.exe» Then Wscript.Echo «You must run this script using the CScript host.» Wscript.Quit End If ? Check for command-line arguments; if any of the required four ? are missing, display the usage message. With Wscript.Arguments If .Named(«computer») = «» Then Usage If .Named(«account») = «» Then Usage If .Named(«password») = «» Then Usage If .Named(«program») = «» Then Usage strComputerName = FixComputerName(.Named(«computer»)) ? Build a job name that consists of the filename and the ? current date/time. strJobName = GetProgramName(.Named(«program»)) & _ « [« & StrDateTime() & «]» ? The «start-in» directory will be a null string if the /startin ? option is not specified on the command line. strStartIn = .Named(«startin») End With ? Enable trace mode if /trace command-line option is present. blnTrace = Wscript.Arguments.Named.Exists(«trace») ?BEGIN CALLOUT A ? Build command line; quote all arguments. With Wscript.Arguments strCommand = «jt /sm «»» & strComputerName & «»»» _ & « /saj «»» & strJobName & «»»» _ & « /sc «»» & .Named(«account») & «»» «»» _ & .Named(«password») & «»»» & « /ctj StartTime=NOW _ Type=ONCE Disabled=0» & « /sj ApplicationName=»»» _ & .Named(«program») & «»» Parameters=»»» _ & .Named(«parameters») & «»» DeleteWhenDone=1» ? Specify a «start-in» directory if required If strStartIn <> «» Then strCommand = strCommand & _ « WorkingDirectory=»»» & strStartIn & «»»» End With ? Output the entire command line if trace mode enabled. If blnTrace Then Wscript.Echo «[TRACE] Command line: _ ?« & strCommand & «?« ?END CALLOUT A ? Run the program and retrieve its exit code; if trace mode is ? active, also display the program?s standard output. lngExitCode = RunCommandLine(strCommand, blnTrace) If blnTrace Then Wscript.Echo «[TRACE] Exit code: « & CStr(lngExitCode) Else Wscript.Stdout.Write «[« & strComputerName & «]: « If lngExitCode = 0 Then Wscript.Echo «Scheduled job ?« & strJobName & «?« Else Wscript.Echo «Error « & CStr(lngExitCode) & _ « scheduling job ?« & strJobName & «?« End If End If Wscript.Quit lngExitCode End Sub