Batch file in pause continue execution after firefox finish the work and will close

0

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
IF NOT ERRORLEVEL 1 PAUSE

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

placidomaio

Posted 2019-01-28T23:19:37.467

Reputation: 31

Answers

0

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.

Doug Deden

Posted 2019-01-28T23:19:37.467

Reputation: 1 568

I will try yout solution soon and inform you about the results, thanks – placidomaio – 2019-01-29T15:37:34.280

Tryed your solution and do not work tha batch file continue to execute commands ignoring /WAIT. – placidomaio – 2019-01-30T23:40:03.510

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 – 2019-01-30T23:45:47.183

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 – 2019-01-30T23:47:55.143

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 – 2019-01-31T01:11:36.430