Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 26th November 2001, 18:19   #1
Smile2Me
Guest
 
Posts: n/a
Talking Automatic uninstall

I'm trying to construct the following:

My setup detects whether or not it has been installed already
and gives a message about this observation. If the user chooses
not to overwrite (so make a backup) then my setup copies everything
it can discover in $INSTDIR to $TEMP and calls the uninstall of the
previous (installed) version. If this uninstall was succesful, the
setup continues installing the new version.

2 problems:

1) is there a way to execute the uninstall "silently"? Normally the
uninstall contains things like "You're uninstalling!!! Continue???".
Can the new setup shut these things down at runtime and run the
uninstall silently?

2) the setup executes the uninstall using ExecWait, but it actually
doesn't wait for the uninstall to be closed. The setup just continues
and (obviously) observes that uninstall was not succesfull. How can I
get the install to wait for the uninstall?


thx, greetz,

- Hendri -
  Reply With Quote
Old 28th November 2001, 16:02   #2
Smile2Me
Guest
 
Posts: n/a
Unhappy please help me out....

does nobody have an answer to my questions above???

Please help me out...

Thx,

- Hendri -
  Reply With Quote
Old 29th November 2001, 02:02   #3
justin
Moderator Alumni
 
Join Date: Apr 2000
Location: USA
Posts: 315
If the uninstaller was generated with 1.7b2 or later, you can do this:
code:

ExecWait '"$INSTDIR\uninst.exe" /S _=$INSTDIR'
Delete $INSTDIR\uninst.exe ; the uninstaller won't be able to delete itself when run above.



And that will silently uninstall and wait. The /S switch will be ignored on earlier uninstallers, but the uninstaller will be executed and waited for though.

-Justin
justin is offline   Reply With Quote
Old 29th November 2001, 05:36   #4
Smile2Me
Guest
 
Posts: n/a
thx...

Thx Justin!

I'll try your solution.

Greetz,

- Hendri -
  Reply With Quote
Old 30th November 2001, 07:05   #5
Smile2Me
Guest
 
Posts: n/a
Detection of silent uninstall

Still a question about this silent uninstall:

How to detect at runtime that my uninstall is run silently?
The problem: the /S parameter disappears from the commandline
at run time, so I cannot check this...

My Uninstall has to know this to be able block usermessages like
MessageBox MB_YESNO "You are uninstalling! Continue?"

Thx,

- Hendri -
  Reply With Quote
Old 30th November 2001, 21:02   #6
eccles
NSIS Dev
 
eccles's Avatar
 
Join Date: Sep 2001
Location: Leicester, UK
Posts: 193
When the uninstaller has _=$INSTDIR passed to it you should find that the problem of other parameters going missing will stop. The uninstaller normally copies to and relaunches itself from the $TEMP directory, but the presence of the _= parameter fools it into thinking this has already happened.

Btw, here's a general purpose function I use for getting parameters from the command-line that hopefully might be useful.
code:
; GetNextParm
; Processes the next parameter, which may be quoted, from the string on the
; top of the stack.
; Usage:
; Push <parameters>
; Call GetNextParm
; Pop <next parameter>
; Pop <remaining parameters>
Function GetNextParm
Exch $0
Push $1
Push $9
Push $8
StrCpy $1 ""

; Trim leading space
TrimLeading:
StrCpy $9 $0 1
StrCmp $9 "" Done
StrCmp $9 '"' DelimitQuote
StrCmp $9 " " "" DelimitSpace
StrCpy $0 $0 "" 1
Goto TrimLeading

; Begin a quote-delimited parameter
DelimitQuote:
StrCpy $0 $0 "" 1
Goto CopyParm

; Begin a space-delimited parameter
DelimitSpace:
StrCpy $9 " "

; Extract the parameter
CopyParm:
StrCpy $8 $0 1
StrCmp $8 "" Done
StrCpy $0 $0 "" 1
StrCmp $8 $9 Done
StrCpy $1 $1$8
Goto CopyParm

Done:
Pop $8
Pop $9
Exch $1
Exch
Exch $0
Exch
FunctionEnd

e.g.
code:
Push $CMDLINE
Call GetNextParm
Pop $0 ; exe name
StrCpy $9 "" ; /S flag

ParmsLoop:
Call GetNextParm
Pop $0
StrCmp $0 "" ParmsDone ; No more parms
StrCpy $1 $0 2
StrCmp $1 "_=" ParmsDone ; No more /useful/ parms
StrCmp $0 "/S" ParmSlashS
Goto ParmsLoop

ParmSlashS:
StrCpy $9 "Y"
Goto ParmsLoop

ParmsDone:
Pop $0 ; Tidy the stack
StrCmp $9 "Y" Silent NotSilent
etc...


Good luck

Dave.
eccles is offline   Reply With Quote
Old 2nd December 2001, 07:20   #7
Smile2Me
Guest
 
Posts: n/a
Talking thx...

Thx Dave,

your solution (GetNextParm) work great!

Besides that I would like to inform you about the fact that the
solution by Justin (with /S parameter and deleting uninstall after
the actual uninstall) doesn't work on slow machines (like mine).

After ExecWait returns, Windows hasn't really shut down the program,
so we cannot delete it. Use something like:

code:-----------------------------------------------------------------
ExecWait '"$INSTDIR\uninst.exe" /S _=$INSTDIR'
Sleep 500 ; wait for the uninstall to close
Delete $INSTDIR\uninst.exe ; the uninstaller won't be able to delete itself when run above.
----------------------------------------------------------------------

This works fine on my machine!

Good luck, thx again Dave, greetz,

- Hendri -
  Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump