Executor Interface Reference

Allows to create a new process. More...

Inheritance diagram for Executor:

Inheritance graph
Collaboration diagram for Executor:

Collaboration graph
List of all members.

Public Member Functions

 Execute ([out, retval] VARIANT_BOOL *Result)
 Creates a new process and its primary thread.
 Wait ([in, defaultvalue(0xFFFFFFFF)] ULONG TimeOut,[out, retval] VARIANT_BOOL *Result)
 Waits for the process completion.
 Terminate ([in, defaultvalue(1)] ULONG ProcessExitCode,[out, retval] VARIANT_BOOL *Result)
 Terminates the process.

Properties

BSTR RW ApplicationName []
 The name of the module to be executed.
BSTR RW CommandLine []
 The command line to be executed.
ULONG R ExitCode []
 Retrieves the termination status of the process.
BSTR RW IntegrityLevel []
 Specifies usage of the Windows Integrity Mechanism.
IDispatch *R Error []
 If the process cannot be started, returns Error object.
VARIANT W OnComplete []
 Sets the event handler for the OnComplete event.

Detailed Description

Allows to create a new process.

See also ExecutorEvents.

Example (JScript):

o = new ActiveXObject("Scripting.WindowSystemObject")

ext = new ActiveXObject("Scripting.WindowSystemObjectExtensions")

f = o.CreateForm(0,0,0,0)

f.ClientWidth = 500
f.ClientHeight = 300
f.CenterControl()

top = 10

for (i = 0; i<3; i++)
{
        f.TextOut(10,top,"Process: "+i);
        
        status = f.TextOut(100,top,"")

        executor = ext.CreateExecutor()
        executor.CommandLine = "calc.exe"
        executor.UserData = status
        executor.OnComplete = function(Sender)
        {
                Sender.UserData.Text = "Completed/"+Sender.ExitCode
        }

        top += 30

        if (executor.Execute())
                status.Text = "Started"; else
                status.Text = "Error"

        
}


f.Show()

o.Run()

Since:
1.1.17.


Member Function Documentation

Execute ( [out, retval] VARIANT_BOOL *  Result  ) 

Creates a new process and its primary thread.

Return values:
Result If "TRUE" - the process is started.

Terminate ( [in, defaultvalue(1)] ULONG  ProcessExitCode,
[out, retval] VARIANT_BOOL *  Result 
)

Terminates the process.

Parameters:
ProcessExitCode The exit code to be used by the process and threads terminated as a result of this call.
Return values:
Result If "TRUE" then the process is terminated.

Wait ( [in, defaultvalue(0xFFFFFFFF)] ULONG  TimeOut,
[out, retval] VARIANT_BOOL *  Result 
)

Waits for the process completion.

Parameters:
TimeOut Timeout in seconds. 0xFFFFFFFF = INFINITY.
Return values:
Result If "TRUE" then the process completed.


Property Documentation

BSTR RW ApplicationName

The name of the module to be executed.

The ApplicationName property can be empty string. In that case, the module name must be the first white space-delimited token in the CommandLine string.

If you are using a long file name that contains a space, use quoted strings to indicate where the file name ends and the arguments begin.

Otherwise, the file name is ambiguous. For example, consider the string "c:\program files\sub dir\program name". This string can be interpreted in a number of ways. The system tries to interpret the possibilities in the following order:

See also:
CreateProcess in the MSDN.

BSTR RW CommandLine

The command line to be executed.

The maximum length of this string is 32K characters.

If ApplicationName is empty string, the module name portion of CommandLine is limited to MAX_PATH characters.

The CommandLine property can be "". In that case, the Executor uses the ApplicationName string as the command line.

IDispatch* R Error

If the process cannot be started, returns Error object.

ULONG R ExitCode

Retrieves the termination status of the process.

BSTR RW IntegrityLevel

Specifies usage of the Windows Integrity Mechanism.

Gets or sets the integrity level for the process.

This parameter can be a one of the following values:

Note. If IntegrityLevel="" then the CreateProcess WINAPI function will be used, otherwise the CreateProcessAsUser.

Note. Only used in Windows Vista and later.

Example (JScript):

o = new ActiveXObject("Scripting.WindowSystemObject")

ext = new ActiveXObject("Scripting.WindowSystemObjectExtensions")

f = o.CreateForm(0,0,0,0)

f.ClientWidth = 500
f.ClientHeight = 300
f.CenterControl()

f.TextOut(10,10,"Integrity level:")

integrityLevel = f.CreateComboBox(100,10,100,25)
integrityLevel.Add("Untrusted")
integrityLevel.Add("Low")
integrityLevel.Add("Medium")
integrityLevel.Add("High")
integrityLevel.Add("System")

label = f.TextOut(10,40,"")

button = f.CreateButton(220,10,75,25,"Start")
button.OnClick = function(){
        executor = ext.CreateExecutor()
        executor.CommandLine = "notepad.exe"
        executor.IntegrityLevel = integrityLevel.Text
        executor.OnComplete = function(Sender){
                label.Text = "Completed/"+Sender.ExitCode
        }
        if (executor.Execute())
        {
                label.Text = "Started"
        } else
        {
                label.Text = "Error/"+executor.Error.Number+"/"+executor.Error.Description+"/"+executor.Error.Comment
        }
}

button = f.CreateButton(300,10,75,25,"Terminate")
button.OnClick = function(){
        executor.Terminate(10)
}

button = f.CreateButton(380,10,75,25,"Wait")
button.OnClick = function(){
        f.MessageBox("Wait result: "+executor.Wait())
}


f.Show()

o.Run()

VARIANT W OnComplete

Sets the event handler for the OnComplete event.

This event occurs when the process completed.


WSO 1.1 Documentation. Date modified:Wed Aug 12 18:12:33 2015. (C) Veretennikov A. B. 2004-2015