I found some (or many?) programs (ex. mspaint.exe, cmd.exe, conhost.exe, notepad.exe) never launch by XRun/XrunAndWait while some (ex. calc.exe) always launch successfully without problem. The same symptoms are observed for both Chrome and Firefox. For example, when I have a single-line macro
it quits by an error showing an alert that no such file is found (cmd.exe, which is launched by conhost.exe, shows the halting symptom on the other hand). Both programs launch without problem by direct double clicking the file in file managers and by calling from PowerSell/cmd.exe with the exactly same file paths.
My system configuration is with Version 5.7.5 for Chrome and 5.7.6 for Firefox both running on the same machine of Windows 10.
I would like to know what is happening behind XRun and XrunAndWait, and hope it would be fixed if it is a bug.
After my further investigation, I found that âsuccessfulâ programs are those immediately return to the caller program by launching the own window asynchronously. In this term, the âhalting symptomâ of XRunAndWait will be the normal behavior, however, the âerror endâ and the âno launch symptomâ of XRun will be still questionable.
The unnatural behavior of XRun is that it seems to be killing the started program just after launching it. I expect from the document that the program should continue to run asynchronously.
As the docs mentioned I linked, it would be impossible to test against every single program out there so launching from a script isnât a workaround but expected behavior. This also give you more flexibility. For example in my scripts when starting another program I wait until it actually sees the process before the script exits which then UIVision sees the exit code and then continues with the macro (For XRun and Wait).
This way if the processor is loaded the delay is perfect. Iâve never had a macro continuing on without the process actually started and this is much better than putting a large static pause in.
I do my scripting in PowerShell so hereâs is how I do it if it helps:
#Start MyProgram from within Macro
Start-Process -FilePath "C:\Program Files\Path\MyProgram.exe"
#wait for process to start
do {
Start-Sleep -Milliseconds 200
} until (Get-Process -Name MyProgram -ErrorAction SilentlyContinue)
exit
It seems that both XRun and XRunAndWait always kill/close/invalidate the windows opened by the invoked program itself (no effect on pure CLI programs), but such action is not taken for grandchild processes launched by the program. This feature (immediate killing/closing/invalidating of directly invoked GUI applications) should be clearly mentioned in the document (not just about the âno wait for closingâ feature) because it is quite different from other RPA tools.
As i mentioned in my first post, both XRun and XRunAndWait couldnât directly launch mspaint.exe, conhost.exe and notepad.exe (cmd.exe is a CLI program so it should be removed from the list) while they successfully launched calc.exe. The law I found is that GUI programs designed to launch the main executables asynchronously succeed and the other GUI programs fail. You can check the types of programs by executing them at Command Prompt or PowerShell.
I have a .bat script that runs fine in cmd. But when I use xRun in Firefox to run it, it fails with return code 1 (Return Code 1: Incorrect function. Indicates that Action has attempted to execute non-recognized command in Windows command prompt cmd.exe.)
Any advice on where I went wrong is greatly appreciatedâŚ
Adding "âexit /B 0â doesnât work too. The exit code can be â0â, but the script doesnât behave the same as when itâs run from CMD.
I tried using another software too, and have got the same result, i.e. exit code is 0 but nothing happens. It works fine in CMD, just like the previous setup.
One question: how many parameters am I allowed when using xRun?