Okay, so I am so confused as to how I should have properly titled my question, so I'll try my best explaining it here.
I am trying to run iMacros and some python scripts by stitching them together in a batch file. Here's a dummy code of what I wanted to to:
"C:\Program Files\Mozilla Firefox\firefox.exe" imacros://run/?m="#Current.iim"
PAUSE
@py %~dp0\SomePythonProgram.py %*
PAUSE
The reason for adding the PAUSE is that the iMacro automation takes a while (about 8 minutes) and that it takes screenshots of certain tabs. The succeeding python program will resize those images, so once iMacros has stopped running, the user has to go back to cmd (if they've gone elsewhere) and press any key before the python program is executed.
The above code ACTUALLY WORKS when Firefox is either already open or RUNNING IN THE BACKGROUND as seen in task manager. Now, when i kill it in task manager prior to running the batch file, instead of the usual "Press any key..." cmd is stuck in this part:
Is there a way to proceed with the rest of the code (perhaps via keypresses /hotkeys)? Or do I need to replace PAUSE with something else? I've tried TRYOUT and it seemed to suffer the same issue. I'm using Windows 10 so SLEEP is not builtin,. would that help me achieve what i want?
I suggest using timeout
and split your commands on a single line using &&
after first command.
The reason for &&
is for the script to only continue to the next item, if the previous command completed successfully. Where timeout /t 600
will wait for 10 minutes before continuing to the next command.
start "" /w /b "C:\Program Files\Mozilla Firefox\firefox.exe" imacros://run/?m="#Test_Macro.iim" && timeout /t 600 & @py %~dp0\SomePythonProgram.py %* & timeout /t 600
If you want to continue to the script, regardless if firefox started successfully, you can just use a single &
.
To learn more on the switches available in cmd commands, you can simply open a cmd.exe
window and type help
This will bring you a long list of commands available, to learn more about each, simply type the command name followed by the switch /?
Here we can use start
and timeout
as an example of help switches :
start /?
timeout /?