Skip to content
⌘ NSIS Forum Archive

HideWindow Doesn't work!

5 posts

Jennifer K#

HideWindow Doesn't work!

I wrote an installer based on the makensis.nsi example.

Function PageLeaveReinstall was copied verbatim, unmodified (except for the registry path for "UninstallString").

But HideWindow inside that function doesn't work!

Function PageLeaveReinstall
  ${NSD_GetState} $R2 $R1
  StrCmp $R0 "1" 0 +2
    StrCmp $R1 "1" reinst_uninstall reinst_done
  StrCmp $R0 "2" 0 +3
    StrCmp $R1 "1" reinst_done reinst_uninstall
  reinst_uninstall:
  ReadRegStr $R1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NSIS" "UninstallString"
  ;Run uninstaller
  HideWindow
    ClearErrors
    ExecWait '$R1 _?=$INSTDIR'
    IfErrors no_remove_uninstaller
    IfFileExists "$INSTDIR\makensis.exe" no_remove_uninstaller
      Delete $R1
      RMDir $INSTDIR
    no_remove_uninstaller:
  StrCmp $R0 "2" 0 +2
    Quit
  BringToFront
  reinst_done:
FunctionEnd 
When I click the "Uninstall before installing" radio button, the uninstaller wizard comes up but if I drag it, the installer wizard becomes visible and I can click it and even see how it completes installation before the poor uninstaller even has a chance to start.

Is this a known bug in nsis?

Tx,
Jen
Jennifer K#
I think I solved the problem?

First let me correct a mistake in my listing above. Instead of
ExecWait '$R1 _?=$INSTDIR' 
I actually wrote
ExecWait '$R1' 
and that was the problem.

As soon as I fixed my code to be exactly what was in makensis.nsi:
ExecWait '$R1 _?=$INSTDIR' 
It started behaving as I wanted: Install doesn't start running before Uninstall is complete.

This is weird. I don't understand this _? thing: I read the entire 4.9.1.4 ExecWait documentation and didn't find any hint as to what it does.

What does _? do?

Tx,
Jen
Comperio#
It's all in help file:
_?= sets $INSTDIR. It also stops the uninstaller from copying itself to the temporary directory and running from there. It can be used along with ExecWait to wait for the uninstaller to finish. It must be the last parameter used in the command line and must not contain any quotes, even if the path contains spaces.
Jennifer K#
Thanks! I did search the NSIS User Manual but couldn't find any mention of it. Apparently the CHM search and index capabilities are not that great.

Now, the help file says that _?= sets $INSTDIR. This is understandable in a statement like
ExecWait '$R1 _?=$INSTDIR' 
But what happens if I write
ExecWait '$R1 _?=$MYBELOVEDVARIABLE' 
Will it also set $INSTDIR or will it set $MYBELOVEDVARIABLE?

Also, where does the weird syntax '_?=' come from?
Is it an assignment to special variable named '_?' ?
Or is it simply an atomic construct to be used as is?

Tx,
Jen
kichik#
The second will not set $MYBELOVEDVARIABLE. Think about it, the executed installer will not even know the command line came from $MYBELOVEDVARIABLE as it will be replaced with its content.