infinity.process¶
Module: infinity.process
Example:
infinity.loadModule('infinity.process')
infinity.process.start('C:/Program Files/Internet Explorer/iexplore.exe', 'https://localhost');
infinity.sleep(3000);
console.debug(infinity.process.kill('iexplore.exe'));
result¶
An object according to this interface is being returned by the start
function.
Properties
error¶
Type: string
Indicates whether an error occured while starting a process.
exitCode¶
Type: number
Gets the exit code of the previously started process.
output¶
Type: string
Gets the output of the previously started process.
success¶
Type: boolean
Indicates whether the starting of a process has succeeded.
correctCmdLineParam()¶
Quotes the string if necessary to ensure that it is interpreted as a single command line parameter (e.g. by enclosing it in quotes if it contains spaces).
Signature:
correctCmdLineParam( param: string ): string
Parameters:
- param:
string
The string to be corrected.
Return type: string
Example:
infinity.loadModule('infinity.process');
let s = infinity.process.correctCmdLineParam(param);
exists()¶
Specifies, whether there is a process with the provided name running in the moment of the function call.
Signature:
exists( processName: string ): boolean
Parameters:
- processName:
string
The process name to check for.
Return type: boolean
Example:
infinity.loadModule('infinity.process');
if ( infinity.process.exists('iexplore.exe') ) {
//...
}
kill()¶
Attempts to kill the process with the specified name.
Signature:
kill( processName: string ): boolean
Parameters:
- processName:
string
The name of the process to kill.
Return type: boolean
Example:
infinity.loadModule('infinity.process');
if ( infinity.process.kill('iexplore.exe') ) {
//...
}
start()¶
Launches the specified executable file as a process with optionally provided parameters. Returns an object with result information according to the infinity.process.result
interface.
Signature:
start( fileName: string, params?: string, waitfor?: boolean, timeout?: number ): infinity.process.result
Parameters:
-
fileName:
string
Filename, relative path (location relative to the folder with the used INFINITY.JS executable file) or absolute path to the executable file which should be launched.
-
params:
string
, optionalCommand line-like parameters which should be provided to the started process.
-
waitfor:
boolean
, optionalSpecifies whether the function should wait for the launched process to complete or be killed, before returning its results.
-
timeout:
number
, optionalSpecifies how long the waiting for the process to complete should last.
Return type: infinity.process.result
Example:
infinity.loadModule('infinity.process');
let resultObject = infinity.process.start('C:/Program Files/Internet Explorer/iexplore.exe', 'https://localhost');
waitFor()¶
Waits for the given process to finish or terminate. Script execution is paused until the process has terminated or the specified number of seconds has passed.
Signature:
waitFor( processName: string, waitFor: number ): boolean
Parameters:
-
processName:
string
The name of the process to wait for.
-
waitFor:
number
Number of seconds to wait for the process to finish or terminate (attention: this parameter is a number of seconds, not milliseconds).
Return type: boolean
Example:
infinity.loadModule('infinity.process');
if ( infinity.process.waitFor('iexplore.exe', 5000) ) {
//...
}