- NSIS Discussion
- autouninstall
Archive: autouninstall
SGI
1st October 2003 17:36 UTC
autouninstall
I have my autouninstall...but when Im running the autouninstaller there is the install window behind him ready.
I want to start the new installation only if is unistalled the old program and stop the installation (new program), if they dont accept the upgrade/cancell.
Thank you
ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROD_NAME}" "uninstallstring"
StrCmp $1 "" cont
StrCmp $0 "" done
cont:
HideWindow
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"This wizard will autouninstall the ${PROD_NAME}. $\n$\nIt is strongly recommended that you uninstall manually any previous versions of \
${PROD_NAME} 2.5.${VER_MINOR}$\n$\nClick `OK` to install or `Cancel` to cancel this upgrade." \
IDOK uninst
Abort
uninst:
ClearErrors
ExecWait '"$INSTDIR\uninstall.exe" /S_?=$INSTDIR'
done:
BringToFront
Afrow UK
1st October 2003 17:45 UTC
If you want to close the installer that runs the uninstaller, use
Exec '"$INSTDIR\uninstall.exe" /S_?=$INSTDIR'
Quit
You could pass a command-line parameter to the uninstaller to be read in the uninstaller to re-run the installer when the uninstall is complete.
E.g.
In installer .onInit
Exec '"$INSTDIR\uninstall.exe" /S_?=$INSTDIR yes'
Quit
In uninstaller
Section Uninstall
...
Call GetParameters
Pop $R0
StrCmp $R0 "/S_?=$INSTDIR yes" 0 noQuit
Exec installer.exe
Quit
noQuit:
SectionEnd
-Stu
Joost Verburg
1st October 2003 18:31 UTC
You'd better send the filename of the installer, because the user might have renamed the file.
See http://nsis.sourceforge.net/archive/...b.php?page=427
Afrow UK
1st October 2003 18:42 UTC
Ah yes!
Thinking about it now, it's probably easier to write the extra parameters to a temp ini file or to the registry, so that a string function isn't required to get hold of the sent command-line parameters.
E.g.
In installer .onInit
Call GetEXEName
Pop $R0
WriteINIStr "$TEMP\myinstaller.tmp" "Installer" "InstallerEXE" "$EXEDIR\$R0"
Exec '"$INSTDIR\uninstall.exe" /S_?=$INSTDIR'
Quit
In uninstaller
Section Uninstall
...
IfFileExists "$TEMP\myinstaller.tmp" 0 noQuit
ReadINIStr $R0 "$TEMP\myinstaller.tmp" "Installer" "InstallerEXE"
Exec "$R0"
Delete "$TEMP\myinstaller.tmp"
Quit
noQuit:
SectionEnd
Joost Verburg
1st October 2003 18:45 UTC
I think using the command line is a good solution.
kichik
1st October 2003 20:07 UTC
A simpler solution would be reading the uninstaller's return value. As stated in C.2 Error Levels, the uninstaller will return 1 if the process failed. Read it using the second parameter of ExecWait. For example:
ExecWait '"$INSTDIR\uninstall.exe" _?=$INSTDIR' $0
StrCmp $0 0 goodToGo
Abort
goodToGo:
BTW, you have an error in your call to the uninstaller. It seems as you've tried to make the uninstaller silent but missed a space after the /S parameter. I have removed it in my example because you've talked about the user clicking the cancel button, which is impossible if the uninstaller is silent.
Joost Verburg
1st October 2003 20:16 UTC
But in that case the installer keeps running. The command line is used to send the installer filename.
kichik
1st October 2003 20:19 UTC
The installer should wait for the uninstaller if using _?=$INSTDIR on the command line.
Joost Verburg
1st October 2003 20:25 UTC
Yes, but it keeps running. It's nicer to close it until the uninstallation has completed.
kichik
1st October 2003 20:29 UTC
HideWindow takes care of that, it shouldn't even show on the taskbar. And if this is used in .onInit, there is nothing to worry about anyway.
SGI
2nd October 2003 18:55 UTC
I never had a moment to try your script "help".
But thank you ....I'll let you know when I have free time.
SGI
9th October 2003 05:06 UTC
I tried your script and I have in thefollowing problem:
this is my script MUI_STARTMENUPAGE_DEFAULTFOLDER "${PROD_NAME}"
and I have the name of the "OutFile" myinstaller1122.ex be carefull no all name of the outfile ....missing letter e.
So far..this is working great if the users dont change the name of the installer:
ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROD_NAME}" "uninstallstring"
StrCmp $1 "" cont
StrCmp $0 "" done
cont:
HideWindow
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"This wizard will autouninstall the ${PROD_NAME}. $\n$\nIt is strongly recommended that you uninstall manually any previous versions of \
${PROD_NAME} 2.5.${VER_MINOR}$\n$\nClick `OK` to install or `Cancel` to cancel this upgrade." \
IDOK uninst
Abort
uninst:
ClearErrors
ExecWait '"$INSTDIR\uninstall.exe" _?=$INSTDIR' $0
StrCmp $0 0 goodToGo
Abort
goodToGo:
done:
BringToFront
I have two choices :
-First: the users are unable to change the name.
-Second: find to do exactly what we want (best choice).
kichik
9th October 2003 12:02 UTC
What does the name of the installer has to do with this? You don't execute it. What exactly do you mean by "find to do exactly what we want (best choice)."?
SGI
9th October 2003 14:12 UTC
I used Afrow Uk script and I have the name of the installer myinstaller1122.ex("OutFile") and there I need my ${PROD_NAME}
MUI_STARTMENUPAGE_DEFAULTFOLDER "${PROD_NAME}"
And what I mean "about" find to do exactly what we want (best choice). is to allow the users to change the name of the installer and autouninstall it.
But I found another problem: if the users changed the name of the previous version the new installer (with autouninstall) doesnt work.
Probably the best way is not to allow to change the name.
kichik
9th October 2003 14:18 UTC
You don't need Afrow's functions anymore. The code in your last post should be enough.
SGI
9th October 2003 15:20 UTC
Thank you Kichik im thinking to use your code...is great.
And going to "not allow to change the name"
SGI
9th October 2003 17:45 UTC
Btw I forgot to tell you ...I wrote that error on the Afrow UK on my installer to try to fix or see if is only a my problem.
I resolved my problem , with your script , but the forum is for all people no just for my script.
Thank you again for your patience.
SGI
12th October 2003 07:00 UTC
Sorry Im back again....the autouninstaller was always triggered
even if no prior version of the program was installed.
kichik
12th October 2003 12:00 UTC
Please attach the entire script.
SGI
12th October 2003 14:46 UTC
Thank you shoot the file....:(
SGI
12th October 2003 14:47 UTC
Sorry and thank you again...in the other post I attached the ini file.
Link to INi file
kichik
12th October 2003 14:55 UTC
There is no place in the script where you actually write to HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROD_NAME}" "UninstallString". If you don't write anything there, the script won't be able to read anything from there. You should also write this key so your uninstaller would be listed in the Add/Remove control panel. See Appendix C - "Add uninstall information to Add/Remove Programs" for more information.