2017-08-09 102 views
-1

我有一個NSIS安裝程序,其中有一些選項可以很好地工作。但是我的「--quiet」選項不適用於卸載程序。如何爲NSIS卸載程序設置選項

 uninst: 
      ClearErrors 
${getOPtions} $CMDLINE "--quiet" $0 
${IfNot} ${Errors} 
      StrLen $2 "\Uninstall.exe /S" 
     ${Else} 
      StrLen $2 "\Uninstall.exe" 
    ${EndIf} 
      StrCpy $3 $0 -$2 # remove "\Uninstall.exe" 
      ExecWait '$0 _?=$3' ;Do not copy the uninstaller to a temp file` 
+0

而不工作意味着什麼? GetOptions失敗或ExecWait失敗? – Anders

+0

命令'「\ Uninstall.exe/S」'永遠不會執行,所以我認爲GetOptions失敗 – sovif

+0

最後,我剛剛嘗試了'ExecWait「\ Uninstall.exe/S」',但出現錯誤並且卸載失敗 – sovif

回答

0

GetOptions期待您來電GetParameters得到的參數,而不是$的CmdLine:

!include FileFunc.nsh 
!include LogicLib.nsh 

... 

${GetParameters} $1 
ClearErrors 
${GetOptions} $1 "--quiet" $2 
${IfNot} ${Errors} 
    MessageBox mb_ok "Quiet mode" 
${EndIf} 

ExecWait "\Uninstall.exe /S"是從來沒有去上班,\ UNINSTALL.EXE意味着UNINSTALL.EXE在當前的根駕駛。你必須使用完整的路徑,它應該看起來像這樣:

StrCpy $0 "$ProgramFiles\my app" ; TODO: Get the old install path 
StrCpy $1 "/S" ; TODO: Set optional parameters 
ExecWait '"$0\Uninstall.exe" $1 _?=$0'