Archive: how to get Add/Remove to not wait on ExecShell?


how to get Add/Remove to not wait on ExecShell?
I have the following code to open an web page when uninstall has finished:

Function un.onUninstSuccess
ExecShell "open" "http://www.google.com/"
FunctionEnd

When running from the Add/Remove applet, I'll see the default browser open as expected. I cannot, however, close the Add/Remove applet until the browser (either IE and Firefox) has also been closed. I think this is because the browser is launched as a child process which causes the applet to wait. When I look in the Task Manager the uninstaller process (Au_.exe) is no longer running.

Does anyone know how to have the Add/Remove applet not wait?

Thanks,
bobics


!include 'WinMessages.nsh'

Function un.onUninstSuccess
FindWindow $0 '' 'Add or Remove Programs'
SendMessage $0 ${WM_CLOSE} 0 0
ExecShell "open" "http://www.google.com/"
FunctionEnd


Thanks a bunch, it works for me.

That's definitely much better than having the Add/Remove applet hang, although the most ideal behavior would be to leave the applet alone. Looks like a problem with the Exec/ExecShell implementation.


Looking for "Add or Remove Programs" window title is a bad solution unless your software only runs on english versions of windows.

There is nothing wrong with the Exec/ExecShell implementation in nsis. The ARP applet works like this by design, on windows 2000 it will only wait for the initial process, on xp it creates a job object and waits for every process created.

Doing Exec '"explorer.exe" http://example.com' might work but will probably not use the default browser but IE


Thanks for the info, previously I did try:

http://nsis.sourceforge.net/Open_link_in_new_browser_window

which comes out to the equivalent Exec '"C:\Program Files\Internet Explorer" http://example.com' but that also hung.

How do I work around this "problem"? I tried a similar test with InstallShield (LaunchApp("C:\\Program Files\\Internet Explorer\\iexplore.exe", "http://www.google.com")) and it does *not* hang the Add/Remove applet.

I can surmise a few reasons for waiting on the job on XP (e.g. a possible separate child uninstall process, setups that spawn a temporary cloned instance so the uninstall exe can be deleted, etc.). I do not believe, however, that this fits the most commmon *expected behavior* for Exec... since if I did want it to wait, I would have used ExecWait. It seems InstallShield figured this out...


Actually, my apologies, it looks like InstallShield has the same behavior as NSIS. (I was dumb and launched it from the wrong location in my test.)

Might not be any way around this.

Also I think using the close window signal still leaves an instance of rundll32 even though there's no UI, which is pretty bad.


The reason I used explorer.exe (Not IE) in my example is that explorer is already running so it will not start a new process (Well it will start and then end right away)


Thanks, you're a genius!


I tried Exec '"explorer.exe" http://example.com', it works on XP and Windows 7, but not Vista. Any idea?

Thanks!


Originally posted by jdt2oo7
I tried Exec '"explorer.exe" http://example.com', it works on XP and Windows 7, but not Vista. Any idea?
Well, it is a hack...

You might try creating a scheduled task to open the url. Set the delay very short - it only needs to be a couple of seconds ahead of the current clock. The ARP process will not see it as a child or part of the job, so they should close (or be closeable) when your uninstaller ends.


Why not just execute as a new process?

http://nsis.sourceforge.net/Escape_A...th_New_Process


Originally posted by Zinthose
Why not just execute as a new process?

http://nsis.sourceforge.net/Escape_A...th_New_Process
I have not updated that code for Vista/7, so I'm not sure if it still works

The ONLY way to launch a URL in a non hacky way is to use a out of process custom COM object (parent process of the COM host .exe would not be in the same process tree as the uninstaller) (You would register the COM dll, use it, unregister, so, it is also a ugly workaround)