Creates a new Windows NT process, optionally waits for the process to exit and returns the exit code. If the process does not end within the specified timeout period, it can be forcefully terminated.
obj.CreateProcess(ExePath String, CommandLine String, Wait Boolean, [TimeOut Long], [ForceTermination Boolean], [ExitCode Long]) Where obj is an OpScrUtil.Utility object.
||Specifies the module to execute. Can be NULL, in which case the module name must be the first white space-delimited token in ExePath.|
||Specifies the command line to execute. Can be NULL, in which case the ExePath is used as the command line.|
||Specifies whether the function waits for the launched process to terminate.|
||Specifies the length of time in seconds to wait for the launched process if Wait was specified. This parameter is optional. Defaults to 120 (default is adjustable in the registry).|
||Specifies whether the function terminates the launched process after the timeout has been reached. This parameter is optional. This parameter returns True or False on return to indicate whether the process was forcibly terminated.|
||Returns the exit code of the launched process. This parameter is optional. Not available if Wait = False|
To launch the
ping command and
retrieve the exit code, terminating the process if it runs longer
60 seconds, enter:
Dim obj, bForceTerminate, ExitCode Set obj = CreateObject("OpScrUtil.Utility") bOK = obj.CreateProcess("", "ping www.missioncritical.com", True, 60, bForceTerminate, ExitCode) If bOK Then strMsg = "The exit code was " & ExitCode If bForceTerminate Then strMsg = strMsg & "The process was forcibly terminated." Else strMsg = "CreateProcess failed: " & obj.GetError() End If