Archive: 1.94 Uninstaller problem.


1.94 Uninstaller problem.
I've got a portion of code which reads the old registry and prompts to uninstall the old version if it's found. Been using this since 1.61. It was fine with 1.91, but I just installed 1.94. Now it says "Error initializing uninstaller," when it tries to run the unistaller executable. It gets this information from the registry key like this:

ReadRegStr $9 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PROGNAME}" "UninstallString"

ClearErrors

Sleep 500
Exec "$9"
IfErrors DisplayMsgBox Fin

Just noticed it when I tried to uninstall a 1.94 built version, but it didn't happen with the version that I last built, which was with 1.91.

Thanks.


Ok.
This problem seems to have cropped up in version 1.80. No problems with 1.70, but anything later than 1.80 and it happens.

I've also noticed this odd UDebugOut.default which is always 0 bytes and has a somewhat random date. Not sure if that's related, but I can't use any of these later versions because I need to be able to spawn off the uninstaller from within an installer. It would be nice if that was a standard option built into the compiler, but I'll be perfectly happen if this can be fixed so it works ok again.

Thanks.


Don't you need to use ExecWait instead of Exec, to wait for the uninstaller to finish?

Since all you are really doing is running the uninstaller exe, that would mean that the uninstaller is not working correctly. Maybe you built the program with a version of NSIS that had a bug in the uninstaller.


Well..

Originally posted by rainwater
Don't you need to use ExecWait instead of Exec, to wait for the uninstaller to finish?

Since all you are really doing is running the uninstaller exe, that would mean that the uninstaller is not working correctly. Maybe you built the program with a version of NSIS that had a bug in the uninstaller.
Yeah, I can try that. I wrote all that stuff 5 or 6 months ago and I know that ExecWait didn't do anything as far as having the uninstaller run first. I'd prefer that behavior because occasionally someone will switch off the installer/uninstaller and then come back and run the installer first and the the uninstaller after and obviously you know what happens. I'll try switching over to ExecWait, but I don't think that's the problem. Long time ago heard someone say something about rundll32 being part of it because on the 9x kernel and ME the uninstaller will almost always fail to launch in the fashion, but it works if you do it "normally." Just need to have that check in there. Tell all the users to make sure to go to the control panel and uninstall the app first, but I also put that check in there again because I know that many of them won't uninstall it first. I'll let you know what happens.

You can always put the uninstaller stuff in your installer. Make a required section that checks for the program and then remove, modify whatever you need to do.


Hmm, yeah that "fixed" the problem. It doesn't wait until the uninstaller finishes, so the behavior is still the same, but it fixed the error with it says the uninstaller can't initialize. So it appears to be a problem with ExecShell in 1.80+ versions.

Thanks.


Ok that wasn't too smart...
You're probably wondering why I'm talking about ExecShell when the code says Exec above. I pasted in the wrong portion, the portion I pasted is for the 9x/ME versions where if the installer fails with ExecShell I have it sleep and try with Exec instead.

Function .onInit

ClearErrors

ReadRegStr $9 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PROGNAME}" "UninstallString"
StrCmp $9 "" Clean PrevInst

Clean:
Goto InitDone

PrevInst:

ReadRegStr $8 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PROGNAME}" "DisplayName"
MessageBox MB_YESNO "$8 found$\nUninstall this version?" IDNO InitDone
;ExecShell "open" "$9" SW_SHOWNORMAL
ExecWait "$9"
;Abort ; causes installer to quit.

IfErrors InstErr InitDone
InstErr:
Call FailedUninst

InitDone:
FunctionEnd

That's what I had and as you can see I took out the ExecShell line and changed it to ExecWait and that fixed that portion of the problem.

Sorry about that...


Another issue I just noticed...
Just noticed this, when the uninstaller finishes, I have it attempt to delete the directory where the files were installed. I then have it try to delete the parent directory. I've always known RMDir to fail if there are files or other directories nested inside the current directory. The reason for attempting to delete the parent directory is because all the apps I have go into their own directory and if you no longer had an of the apps installed, it should delete the main directory so everything is gone.

Anyway, I just noticed that it's no longer wanting to delete the current directory. So, I put in a messagebox to see if the variable was messed up some how, and it wasn't. However, when I do that it correctly deletes the directory. So I tried putting in a sleep instead, but that didn't work either. Any ideas on this problem?

Thanks.