Function to execute a command line statement. The function creates a batch file and runs the code that is provided. Execution of the script can be halted while the batch file executes.
Instead of this function, you can also use
RoboHelp.executeCommandline. This function precedes the method in RoboHelp and is retained for backwards compatibility. The library itself uses
ExecuteBatchFile() to stay compatible with older RoboHelp versions.
The batch file is created in the directory of the current project. When the batch file is done, the batch file is deleted. When there is no current project, the batch file is created in
Note: The script automatically adds a line to the batch file that deletes the batch file after the batch file has run. If you change this behaviour and the batch file is not deleted, the function will halt the script indefinitely if the functions waits for the batch file to execute.
To execute a batch file and wait for the batch file to execute:
var batch = "del C:/myfile2.txt\n"; batch += "rename C:/myfile.txt C:/myfile2.txt"; ExecuteBatchFile(batch);
To execute a batch file while not waiting for the batch file to execute:
var batch = "del C:/myfile2.txt\n"; batch += "rename C:/myfile.txt C:/myfile2.txt"; ExecuteBatchFile(batch, false);
Note: If you want to use multiple batch commands, you need to put each command on a new line. You create a new line by adding
\n to your string.
|command||string||Yes|| The command to execute. Add multiple commands by adding a line break (
|waitforbatch||boolean|| If set to
|true||Command executed. Errors that occurred during batch execution are ignored|
|false||Could not execute command|