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?

user692942
  • 16,398
  • 7
  • 76
  • 175
  • Maybe an idea, could you try with the `-new-instance` option. – Keith Jul 09 '19 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 '19 at 08: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 '19 at 08:56
  • @Lankymart Is that a hypothesis or something you've determined for sure? If the latter, how did you determine it? – RockPaperLz- Mask it or Casket Jul 10 '19 at 11:32
  • 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 '19 at 11:37
  • @Lankymart Thanks. Is there another way using WSH or a batch file to wait for an application to close before proceeding? Where would I ask that question, on this SE or on Super User? – RockPaperLz- Mask it or Casket Jul 10 '19 at 20:35
  • What if you use the [command line argument](https://developer.mozilla.org/en-US/docs/Mozilla/Command_Line_Options) `-no-remote`? – dbc Jul 10 '19 at 20:45
  • @RockPaperLizard The current script would wait for an application to close before continuing, try with `notepad.exe` and see how it works. So the issue isn't the script as I keep saying it's how the FireFox executable process has changed, you may need to try detecting the child processes and waiting for them to close. – user692942 Jul 11 '19 at 05:39
  • 2
    @RockPaperLizard FYI - this question was discussed for closure [here](https://chat.stackoverflow.com/transcript/41570?m=46730146#46730146). The majority of participants thus far feel this question is on-topic on Stack Overflow. – Makyen Jul 11 '19 at 16:43

0 Answers0