Skip to content
⌘ NSIS Forum Archive

nsis2 ignores commandline flags to uninstaller?

8 posts

honold#

nsis2 ignores commandline flags to uninstaller?

if i messagebox $0 after popping it, it clearly shows '/S'. my strcmp fails to make it jump to the end section (skipping the warning). with 1.98 this worked properly.

Function un.InstallWarning
  Call un.GetCommandLineArguments
  Pop $0
  StrCmp $0 '/S' end
  ReadRegStr $1 HKLM "SOFTWARE\XXX\" InstDir
  MessageBox MB_YESNO|MB_ICONEXCLAMATION "WARNING: THIS WILL DELETE
THE ENTIRE $1 DIRECTORY INCLUDING ANY FILES YOU MAY HAVE ADDED OR
CHANGED.  CONTINUE?" IDYES end IDNO nouninstall
  nouninstall:
  quit
  end:
FunctionEnd
Function un.GetCommandLineArguments
  Push $0
  Push $1
  Push $2
  StrCpy $0 $CMDLINE 1
  StrCpy $1 '"'
  StrCpy $2 1
  StrCmp $0 '"' loop
    StrCpy $1 ' '
  loop:
    StrCpy $0 $CMDLINE 1 $2
    StrCmp $0 $1 loop2
    StrCmp $0 "" loop2
    IntOp $2 $2 + 1
    Goto loop
  loop2:
    IntOp $2 $2 + 1
    StrCpy $0 $CMDLINE 1 $2
    StrCmp $0 " " loop2
  StrCpy $0 $CMDLINE "" $2
  Pop $2
  Pop $1
  Exch $0
FunctionEnd 
honold#
note: silent installs tested during the INSTALL portion of the app (also flagged as /S) function properly in 2.0b0 with no code changes. it only appears to affect the uninstall section.
kichik#
Try MessageBox MB_OK _$0_ and see if there are no spaces there or anything else that might kill the StrCmp.
honold#
wow, good idea

it is catching a space AFTER the /S, but there isn't one there when i'm running...

verified running from a shortcut and from the commandline

it would appear that it's inserting its own space after the /S!
honold#
as expected, inserting a space in the strcmp does yield desired output. this does look like a bug, but that's an easy workaround for now.
kichik#
OK, I have checked it out again and the problem is not only with the uninstaller. Your check won't work if the user adds another switch, or spaces by himself.

That's why I have written IsSilent which can be found at the archive: