StartProcess
%StartProcess function
Function
Function creates a new process. The new process then runs the specified executable file in the security context of the specified credentials (user, domain, and password).
Declaration
INT %StartProcess(
TEXT in userName,
TEXT in domain,
TEXT in password,
TEXT in applName,
TEXT in commandLine,
TEXT in currDir,
BOOL in bSync,
INT in timeout,
BOOL in bHide
)Note
userName | String specifying the name of the user. This is the name of the user account to log on to. If you use the UPN format, user@DNS_domain_name, domain parameter must be an empty string. |
domain | String specifying the name of the domain or server whose account database contains the userName account. If this parameter is an empty string, the user name must be specified in the UPN format. |
password | String specifying the clear-text password for the userName account. |
applName | String specifying the module to execute. The specified module can be a Windows-based application. It can be some other type of module (for example, MS-DOS or OS/2) if the appropriate subsystem is available on the local computer.
If the executable module is a 16-bit application, applName should be empty string, and the string commandLine should specify the executable module as well as its arguments. |
commandLine | String specifying the command line to execute.
|
currDir | String specifying the current drive and directory for the new process. The string must be a full path which includes a drive letter. If this parameter is an empty string, the new process has the same current drive as the system service that creates the process. (This feature is provided primarily for shells that need to start an application and specify its initial drive and working directory.) |
bSync | The parameter specifies, whether the script waits for termination of the started process.
|
timeout | The maximum runtime of the started process. The parameter can be used only when bSync=@TRUE. |
bHide | Boolean type parameter - possible values:
|
Return value
Return value is Int type and
is invalid if were unable to run the process
is equal to the value of _ERR_TIME_OUT, if bSync=@TRUE and the timeout was exceeded
is equal to 0, if bSync=@FALSE and the process has been started
otherwise it gets the value of the return code of the process
Note
If unsuccessful, the function writes an error log to the file event.log.
Example
Starting the MS Excel program with opening the file C:\TEMP\WorkBook1.xls.
MS Excel has been installed into C:\Program Files\/Microsoft Office\Office\excel.exe.
Name of the local user is Adm and the password is pwd.
BEGIN
TEXT _cmdLine
INT _retCode
_cmdLine := %Chr(34) + "c:\Program Files\Microsoft Office\Office10\EXCEL.EXE" + %Chr(34) + "c:\temp\Workbook1.xls"
_retCode := %StartProcess("Adm", "", "pwd", "", _cmdLine, "c:\temp", @TRUE, 30, @FALSE)
IF _retCode\VLD THEN
IF _retCode = _ERR_TIME_OUT THEN
; MS Excel was not terminated in the timeout of 30 seconds and was enforced to close
ELSE
; MS Excel was terminated in the timeout of 30 seconds and _retCode contains the return code
ENDIF
ELSE
; cannot to start the program
; the path c:\Program Files\Microsoft Office\Office10\EXCEL.EXE doesn't exist, or cannot log on the user
ENDIF
ENDRelated pages: