2

For years, the following code I wrote has worked to launch Firefox from a script and then perform a set of actions after the user closes it.

/* Launch Firefox and then wait for the user to close it */
var Shell = WScript.CreateObject("Wscript.Shell");
Shell.Run("\"[Firefox Installation Folder]\\firefox.exe\" -profile \"[Firefox Profile Folder]\"", 1, true);
/* After Firefox closes, perform actions... */

The value of "true" at the end of the Shell.Run command previously worked to wait until Firefox had closed. From the docs:

WaitOnReturn

Optional. A boolean value indicating whether the script should wait for the program to finish executing before continuing to the next statement in your script. If set to true, script execution halts until the program finishes, and Run returns any error code returned by the program. If set to false (the default), the Run method returns immediately after starting the program, automatically returning 0 (not to be interpreted as an error code).

For some reason, starting in Firefox 68.0, this no longer works. Firefox runs just fine, but the above script fragment continues to progress as if the user has closed Firefox (even though they have not).

What is causing this, and how can it be fixed?

I need to run several commands after Firefox has been closed by the user, but not while it is running. How can this be done?

9
  • Maybe an idea, could you try with the -new-instance option.
    – Keith
    Jul 9, 2019 at 21:34
  • 1
    Change in architecture maybe. Does FireFox now spawn a new process after executing firefox.exe so the original process is short-lived perhaps?
    – user692942
    Jul 10, 2019 at 8:36
  • It looks as though something has changed with the FireFox architecture, so unclear why you are asking this here. The script can only detect if a process is closed. If the architecture has changed the script won't work.
    – user692942
    Jul 10, 2019 at 8:56
  • 1
    It’s absolutely an hypothesis. All I know for sure is WScript.Shell does not change, so if it was working and now isn’t it’s FireFox where the issue lies and if that is the case what could FireFox had done that would change that functionality. The conclusion being the script isn’t the issue which doesn’t make it a programming problem as such. From what i’ve read in release 68 the multi process (which has been around for a while) can no longer be disabled through flags, so you might be falling foul of that.
    – user692942
    Jul 10, 2019 at 11:37
  • 2
    @RockPaperLizard FYI - this question was discussed for closure here. The majority of participants thus far feel this question is on-topic on Stack Overflow.
    – Makyen
    Jul 11, 2019 at 16:43

0

Your Answer

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

Browse other questions tagged or ask your own question.