Archive: Spawned uninstaller instance


Spawned uninstaller instance
  Hello.
I need to insert MUI_UNPAGE_CONFIRM and disable a message in my uninstaller while running it from the installer. To detect if the uninstaller was spawned, I made-up a commandline switch "/U".

ExecWait "$UNINSTSTR /U _?=$UNINST\\bin" 

Is there an easier way?

The problem is inserting the confirm unpage macro inside a function that causes a compile-time error: command PageEx not valid in a Function.
; Un-Confirm page


>Function un.confirm
StrCmp $SPAWN"1" done
!insertmacro MUI_UNPAGE_CONFIRM
done:
>FunctionEnd
>
By way of explaining how I arrived at this point, I have two functions in the uninstaller that test for the /U switch.

Variables

>Var SPAWN

>; Search in a string from right to left
>; Usage:
; Push "this is a long ass string"
>; Push "ass"
>; Call (un.)StrStrRight
>; Pop $R0
>; ($R0 at this point is "ass string")
Functionun.StrStrRight
Exch $R1; st=haystack,old$R1, $R1=needle
Exch ; st=old$R1,haystack
Exch $R2; st=old$R1,old$R2, $R2=haystack
Push $R3
Push $R4
Push $R5
StrLen $R3 $R1
StrLen $R4 $R2
IntOp $R4 $R4- 1
loop:
StrCpy $R5 $R2 $R3 $R4
StrCmp $R5 $R1 done
StrCmp $R5"" done
IntOp $R4 $R4- 1
Goto loop
done:
IntOp $R4 $R4 + 1
StrCpy $R1 $R2"" $R4
Pop $R5
Pop $R4
Pop $R3
Pop $R2
Exch $R1
FunctionEnd

>; Return length from end of string
>; Usage:
; user variable "SPAWN" equals characters to end of string
>; where "/U" is the last commandline parameter, the output contains 1
>Function un.spawn
Push $CMDLINE
Push "/U"
Call un.StrStrRight
Pop $R0
StrLen $SPAWN $R0
FunctionEnd

>Function un.onInit
Call un
.spawn
>...
>FunctionEnd
>
PS: Potentially, you could hard-code the switch and query with 'IfSpawned', similar to 'IfSilent' ... just an idea.

edit:

Almost forgot. "Normally" you skip pages with an Abort call in a custom function. Normally. Aborting unpage confirm, aborts the uninstaller.

Confirm page


>!define MUI_PAGE_CUSTOMFUNCTION_PRE un.confirm
>!insertmacro MUI_UNPAGE_CONFIRM

>Function un.confirm
StrCmp $SPAWN"1" done
Abort
done:
>FunctionEnd
>
Why?

My uninstaller script has few twists in it. It should be straightforward and yet pages aren't skipped. I've tried Abort with MUI_UNPAGE_WELCOME too and it only aborts the application. When I run the uninstaller alone or, when I launch it from the installer without any precondition, a pure Abort page callback, simply, well... aborts.


Yep. Calling the Abort function in un.onInit wasn't the brightest thing I ever did. Crap happens.


So does Abort in the pre function work or not?


The PRE function works, it skips the page. It did not abort the uninstaller. I was confused. The uninstaller aborted from un.onInit and you can't put !insertmacro MUI_UNPAGE_CONFIRM into a function that skips the page. Really confused.


ExecWait:
The NSIS documentation insists on an extra pair of quotes to delimit the command proper from the commandline parameters, or "it [ExecWait] will not work on Windows 9x with or without parameters". I'm less than convinced this applies also where the command is stored in a variable. I ran an uninstaller with ExecWait on 95 and 98 and not having additional quotes didn't give me problems, although putting the command in quotes is probably safer.


ExecWait '"$UNINSTSTR" /U _?=$UNINST\\bin' 

It works.