Archive: Timing issue using ExecWait in Uninstall section


Timing issue using ExecWait in Uninstall section
hi all,

i'm having a timing issue with ExecWait in the uninstall section.

the first ExecWait calls the Apache Tomcat uninstaller. The second calls MSI to uninstall java.

PROBLEM 1): ExecWait doesn't wait. Both the tomcat uninstaller and java uninstaller launches at the same time. I want tomcat to uninstall and when complete, then have the java uninstaller called, then RMDir the java directory.

PROBLEM 2): Since both uninstallers are called at the same time, if i click 'ok' for both uninstallers, they complete successfully and then the ExecWait for java is called again!? it's as if ExecWait completed and then looped back ran the java uninstaller again...

Thanks again in advance for your help!


----The following is in the 'Section Uninstall'----

;---CALL TOMCAT UNINSTALLER
ExecWait 'C:\Apache\Tomcat50\Uninstall.exe'

;---CALL JAVA UNINSTALLER
ExecWait 'MsiExec.exe /X{26A24AE4-039D-4CA4-87B4-2F83216011FF}'
RMDir "C:\Convio\Java"


So this might not be the best solution:
but for removing the directories after the two (apache and java) uninstallers are complete, i placed my 'RMDir' lines within the 'Function un.onUninstSuccess' and used a messagebox (which displays behind the two uninstaller windows) as a delay. So, the Apache uninstaller/ Java uninstallers are running, when they finish user hits 'done' and then sees the messagebox they hit 'ok' and then the 'Apache' and 'Java' dir. are removed.

Although RMDir "$INSTDIR" doesn't work (it's empty)...

And i can't seem to figure out why the apache and tomcat installers get called simultaneously and twice?


----
Function un.onUninstSuccess
MessageBox MB_OK "$(^Name) was successfully removed from your computer."
RMDir "C:\Apache"
RMDir "C:\Java"
RMDir "$INSTDIR"
FunctionEnd


PROBLEM 1): ExecWait doesn't wait.
If ExecWait doesn't wait, then this probably means:
The executable you run (e.g. the Tomcat uninstaller) runs another executable and exits.
NSIS only waits for the first process to terminate, it does NOT wait for any child processes!

Also this is a common behavior of uninstallers:
When you run "uninstall.exe" it will copy itself to %TEMP% and execute that copy.
The copy will perform the actual uninstall, so the original "uninstall.exe" can be deleted.
NSIS uninstallers work that way too!

right. why the "double call"? so both ExecWait's get called (the tomcat uninstall is built with NSIS!), after they complete and i hit 'ok', the second ExecWait command is called again, prompting me if i want to uninstall java, then it fails if i hit 'ok' since java isn't present anymore...

thanks!


ExecWait 'C:\Apache\Tomcat50\Uninstall.exe'
ExecWait 'MsiExec.exe /X{26A24AE4-039D-4CA4-87B4-2F83216011FF}'


what about this:

since 'Function un.onUninstSuccess; gets called after 'Uninstall section', i could call the tomcat uninstaller in the 'Uninstall section' then call the java uninstall in the 'Function un.onUninstSuccess'.... do you foresee any problems or a better way to do the above?

thanks so much for the quick replies!


Originally posted by zoomzoom
right. why the "double call"?
As explained before: When you run the Uninstaller executable, it may launch another executable and then terminate immediately. Then only the child process is still running. But the process created by NSIS has terminated. Hence ExecWait will return! Many uninstallers work like that: As "Uninstall.exe" is usually located in the install folder, the uninstaller cannot remove the install folder, as long as "Uninstall.exe" is still running. Or in other words: The uninstaller cannot delete itself. To solve the problem: The uninstaller will copy itself (or some helper application) to %TEMP% and then exit. Now the second process (located in %TEMP%) will perform the actual uninstall. This way the entire install folder can be removed, including the "Uninstaller.exe" file, as that file isn't running any longer...

I assume that Tomcat's uninstaller works exactly like that ;)


Originally posted by zoomzoom
what about this:

since 'Function un.onUninstSuccess; gets called after 'Uninstall section', i could call the tomcat uninstaller in the 'Uninstall section' then call the java uninstall in the 'Function un.onUninstSuccess'.... do you foresee any problems or a better way to do the above?

thanks so much for the quick replies!
I don't see the sense in this. Sounds like an ugly workaround.

Better analyze the Tomcat uninstaller and find a method to call it in a proper way...

is it possible to do the equivalent of 'ExecWait' on a function call.

for example: ExecWait FunctionBlah

thanks!


Call already does this. You actually can't do the opposite. There's no "Exec FunctionBlah".


so the Tomcat uninstaller called 'nsexec' a couple times, thus the reason why 'execwait tomcatUninstaller' didn't wait.

i ended up adding a function to uninstall tomcat (instead of calling the tomcat uninstaller). this was easy because apache makes their nsis script available, so i could see how they wrote the uninstall script and adapt it as needed.

however, if i didn't have access to the tomcat script, i'm not sure how one would get around 'execwait' not working in this type of parent/child process scenario...

thanks all for your help!!