I have a batch file that checking the internet connection, if the connection internet is up, launch firefox with a macro and go on pause.

During this time fiefox works with the macro, after firefox finish the work automatically close.

Now i need to continue the code of the batch opened after firefox finished the works and will be closed but batch file reast in pause.

Exist a solution to continue the batch file opened without manual intervention ?

With firefox I can run another batch file or a software (using some javascript) but i need to continue the execution of batch file opened and I can not find any solution to continue the batch file.

This is the code of my batch file (ping to check connection, sound to alert me, start firefox with macro, pause batch file)

PING -n 5 www.wikipedia.org|FIND /I "TTL">NUL
IF NOT ERRORLEVEL 1 rundll32 user32.dll,MessageBeep 0x00000010L
IF NOT ERRORLEVEL 1 start "" "D:\Programmi Installati\Firefox\FirefoxPortable.exe" imacros://run/?m=work.iim

I do not know how long it takes for firefox to complete the job so I use the pause command.


You can add the /WAIT parameter to the line that starts Firefox.

IF NOT ERRORLEVEL 1 start "" /WAIT "D:\Programmi Installati\Firefox\FirefoxPortable.exe" imacros://run/?m=work.iim

That will then wait until Firefox exits before moving on to the next line of the batch file.

Caution: not all executables will work this way. For example, if you use this approach to launch Microsoft Word (winword.exe), the batch file will continue without seeming to wait for Word to finish. This is because Winword.exe is a stub which launches the main Word application and then exits.

See this description of the Start command for more details.

  • I will try yout solution soon and inform you about the results, thanks – placidomaio Jan 29 '19 at 15:37
  • Tryed your solution and do not work tha batch file continue to execute commands ignoring /WAIT. – placidomaio Jan 30 '19 at 23:40
  • It is possible that my test (FireFox.exe) respects the /Wait parameter, but your case (FireFoxPortable.exe) does not. Perhaps FireFoxPortable.exe is just a stub, much like winword.exe. – Doug Deden Jan 30 '19 at 23:45
  • It's possibile the imacros://run/?m=work.iim is incompatible with /WAIT commands, after i lanched my batch file it continue to execute commands and firefox not have time to complete the work. – placidomaio Jan 30 '19 at 23:47
  • So take out the imacros... part and see what happens. If Firefox starts, but the batch file waits until you close Firefox, then you know that the imacros parameter is at least partially to blame. But if the batch file continues processing, then something about the way FireFoxPortable.exe is launching is making the batch file think that Firefox has finished. – Doug Deden Jan 31 '19 at 1:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.