Search code examples
caplcanoe

In CAPL, is there any function to start/open an executable in background?


I would like to run an executable from a CAPL script. Is there any function for that?
I am looking for a function which will run an executable in the background. E.g. if a certain message is received, then start an application.
Is there any possibility in CAPL for that?


Solution

  • Yes, there are two functions to do that:

    long sysExec(char cmd[], char params[]);
    long sysExec(char cmd[], char params[], char directory[]);
    
    long sysExecCmd(char cmd[], char params[]);
    long sysExecCmd(char cmd[], char params[], char directory[]);
    

    These functions execute an external command. They do not wait until the command has completed its execution. The return value is 1 if the command was successfully started; otherwise, 0. Note that no return value from the command itself will be returned because the call does not wait for the command to finish.

    sysExec must be given an executable; sysExecCmd calls cmd.exe /K with the first parameter, which opens a command window where the command is executed as if it was entered directly.

    Note that in case of a distributed simulation environment using a VN8900 device, a real-time module (VT 6000 family) or a CANoe RT server, sysExec executes the requested command on the remote platform.

    Here is an example:

    sysExec("C:\\windows\\notepad.exe", "");