kalverson
2nd September 2010 19:55 UTC
silent uninstall in oninit
I am having a bit of trouble getting this to work:
; Silent uninstall of previous program
ReadRegStr $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\my program" "UninstallString"
ExecWait '"$1" /S' $0
MessageBox MB_OK "$1 /S exit code $0"
The path and program read is correct. The exit code is zero. The uninstall program is not executed.
Darn, what could be happening here. The command works fine in a command shell.
Afrow UK
2nd September 2010 20:47 UTC
Firstly, http://nsis.sourceforge.net/When_I_u...he_uninstaller.
Secondly, try without /S.
Stu
kalverson
2nd September 2010 21:06 UTC
Thanks for the reply. I have no doubt that firstly and secondly will work for most people. There just seems to be something a bit odd for me. I tried both and neither worked for me. secondly resulted in an error dialog titled "NSIS Error" with the text of "Error launching installer". I may have to resort to compiling my own exe that calls the uninstall the way I want to run it under the covers; i.e. silently and in background. The uninstall does run ok when I launch it in a command shell using the full path in double quotes.
Afrow UK
2nd September 2010 21:21 UTC
Well you definitely need the _? switch otherwise ExecWait will not wait. As for that error, I forget what causes it. Try using SetOutPath first.
Stu
kalverson
3rd September 2010 12:15 UTC
I tried using just a ShellExec with no parameters and options and found that these lines of code at the beginning of my oninit were the culprit:
; From Appendix C.11 Prevent Multiple Instances (Useful Scripts)
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${PRODUCT_NAME}_mutex") i .r1 ?e'
Pop $R0
StrCmp $R0 0 +3
MessageBox MB_OK|MB_ICONEXCLAMATION "The ${PRODUCT_NAME} installer is already running."
Abort
You just don't get to see the problem when you try to run silently. Problem solved. Thanks Stu for trying to help me. Your the greatest.