Archive: autouninstall


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


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


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


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


I think using the command line is a good solution.


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.


But in that case the installer keeps running. The command line is used to send the installer filename.


The installer should wait for the uninstaller if using _?=$INSTDIR on the command line.


Yes, but it keeps running. It's nicer to close it until the uninstallation has completed.


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.


I never had a moment to try your script "help".
But thank you ....I'll let you know when I have free time.


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).


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)."?


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.


You don't need Afrow's functions anymore. The code in your last post should be enough.


Thank you Kichik im thinking to use your code...is great.
And going to "not allow to change the name"


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.


Sorry Im back again....the autouninstaller was always triggered
even if no prior version of the program was installed.


Please attach the entire script.


Thank you shoot the file....:(


Sorry and thank you again...in the other post I attached the ini file.

Link to INi file


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.