Skip to content
⌘ NSIS Forum Archive

Calling Uninstaller from Installer...

9 posts

jcagle#

Calling Uninstaller from Installer...

Can someone give me a hand? I want to run the uninstaller from my installer, then continue with the installation. The catch is, if I call the uninstaller from the installer, I want to skip some things in the uninstaller. If I double click the uninstaller, I want to do everything in the uninstaller. So, below is what I have attempted. However, it doesn't appear to call the uninstaller. Any suggestions would be very welcomed!!! Thanks in advance!!!

In the Uninstall Section...
Call un.GetParameters
Pop $0
StrCmp $0 "upgrade" skipit
MessageBox MB_OK "I am here"
skipit:

Here is the call from the installer...
ExecWait '"$INSTDIR\uninstall.exe upgrade" _?=$INSTDIR'

I put the "_?=$INSTDIR" on this line because I read somewhere that that is needed to make the installer script wait for the uninstaller to finish. If that's not the case, please let me know.
jcagle#
Outside of the double quotes...correct? Not the single quotes?

Also, is it correct to have "_?=$INSTDIR"? I would like to delete the directory at the end of the uninstall...but, this might not allow it because the directory is not empty???
kichik#
Yes, outside of the double quotes. It should look like this:

ExecWait '"$INSTDIR\uninstall.exe" update _?=$INSTDIR'

It's OK to have the _?= part, and it must be there if you want the installer to really wait for the uninstaller. You won't be able to delete $INSTDIR from the uninstaller because the uninstaller won't copy itself because of the _?= part. If you want to delete it, copy the uninstaller to $TEMP yourself and then call it with _?= from temp. For example:

GetTempFileName $0
CopyFiles /SILENT $INSTDIR\uninstall.exe $0
ExecWait '"$0" update _?=$INSTDIR'
jcagle#
Cool, that actually makes sense to me!?!?!?! (I'm new, if you can't tell) 😁

Is GetTempFilename a built-in function, or is it a function I must put in my script?

Thanks so much!!
kichik#
GetTempFileName is a built-in instruction. Functions that are not built-in are called using the Call instruction. For example:

Call myFunction

Another possibility of something that's not built-in is plug-ins. For example:

PluginName::FunctionName
Afrow UK#
There are all the cool functions and plugins on the NSIS Archive:


-Stu 🙂
superwan#
hello... I'm sorry to "up" this topic, but I don't understand it really...

this is my code :


SetOutPath "$TEMP"
WriteUninstaller "$TEMP\setup_KTV_tmp.exe"

;écrit dans le KTVsetup.ini qu'il est en train d'installer


WriteIniStr "$TEMP\KTVsetup.ini" "setup" "type" "install"

;Lance le désinstalleur en fenêtre, cache l'autre fenêtre (qui de toute façon est déjà cachée avec le silentinstall silent)

HideWindow
ClearErrors
ExecWait '$TEMP\setup_KTV_tmp.exe _?=$TEMP'
IfErrors no_remove_uninstaller
ReadRegStr $0 HKLM Software\K!TV ""
StrCpy $INSTDIR "$0"
SetOutPath $INSTDIR
WriteUninstaller "$INSTDIR\UninstKTV.exe"
BringToFront

no_remove_uninstaller:
Delete "$TEMP\setup_KTV_tmp.exe"
and my execwait doesn't wait :L


where is my error ?

thx for your answers 😉
superwan#
sorry....


this works 🙂 :


ExecWait '"$TEMP\setup_KTV_tmp.exe" _?=$TEMP'



(quoting problem)
(i'm really dumb 😁 )