Some programs don't launch by XRun/XrunAndWait

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

| XRunAndWait | C:\Windows\System32\mspaint.exe | |,

it halts without showing any new window/dialog, and when I have another macro

| XRunAndWait | C:\Windows\System32\conhost.exe | |,

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.

So the tentative workaround will be using XRunAndWait via a launcher batch file:

start /b mspaint

Nevertheless, the problem of XRun will be an issue to be fixed.

It’s actually not a bug:

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)


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.

Two things:

  • I also use a XRUN plus batch file method because it gives me more control

  • But for this:

Do you have an example exe to test this? If I launch notepad.exe with XRUN it stays open, or?

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 also ONCE (not easily reproducible) observed that LibreOffice showed its splash banner but disappeared immediately and left zombie processes.

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…


XRunAndWait | C:\Users\Administrator\Downloads\mailsend.bat | S76S |

My .bat file:

mailsend.exe -to -from -sub “Subject Line…” -starttls -port 26 -auth -smtp -user blahblah -pass ***** -attach “%1.pdf” -read-timeout 10 -v

Does it work if you add exit /B 0 to the end?

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?