2014-09-10 50 views
0

我們有我們的安裝程序,其中有一些選擇創建快捷方式 1)當前用戶 2創建快捷方式)爲所有用戶 3)創建快捷方式不會創建任何快捷三種選擇在快捷方式選項

第一個選項被檢查爲默認,如果我檢查其他任何工作良好..問題是,如果我檢查例如第三選項,移動到下一頁,回來有2個選擇檢查 - 第1(默認)和第3(選定)。

我對NSIS很新,找不到比我更好的方式,因爲代碼對我來說不是很友好。 我將不勝感激。

感謝,

這是我在我的安裝選項的.ini:

[Field 5] 
Type=GroupBox 
Left=1 
Right=-1 
Top=80 
Bottom=144 
Text="Choice of shortcuts:" 
State="" 

[Field 6] 
Type=RadioButton 
Left=10 
Right=-10 
Top=96 
Bottom=108 
Text="Create shortcuts for all users" 
State=1 
Flags=GROUP|NOTIFY 

[Field 7] 
Type=RadioButton 
Left=10 
Right=-10 
Top=112 
Bottom=124 
Text="Create shortcuts only for a current user" 
State=0 
Flags=NOTIFY 

[Field 8] 
Type=RadioButton 
Text="Do not create shortcut" 
Flags=NOTIFY 
State=0 
Left=10 
Right=-10 
Top=128 
Bottom=140 

再後來在NSIS腳本:

IntCmp $ShortcutsForAllUsers 1 ShortcutsForAll ShortcutsForCurrentUser ShortcutsForCurrentUser 

ShortcutsForAll: 
SetShellVarContext all 
goto done 

ShortcutsForCurrentUser: 
SetShellVarContext current 
goto done 

NoShortcuts: 
goto done 

done: 
FunctionEnd 
+0

也許你可以試試nsDialogs。您使用的這個InstallOption插件非常陳舊,現在它已被棄用,可能會導致此問題。 – Slappy 2014-09-11 13:21:45

回答

0

的InstallOptions頁面應該記住它的狀態只要你不在頁面中每次提取創建回調函數。

!include LogicLib.nsh 
!include InstallOptions.nsh 
ChangeUI All "${NSISDIR}\Contrib\UIs\modern.exe" 

Function .onInit 
!insertmacro INSTALLOPTIONS_EXTRACT_AS "...\test.ini" "iosp.ini" 
FunctionEnd 

Var ShortcutMode 

Page Custom MyShortcutPageCreate MyShortcutPageLeave 
Page Components 
Page InstFiles 

Function MyShortcutPageCreate 
!insertmacro INSTALLOPTIONS_DISPLAY "iosp.ini" 
FunctionEnd 

Function MyShortcutPageLeave 
!insertmacro INSTALLOPTIONS_READ $0 "iosp.ini" "Settings" "State" 
${If} $0 > 0 
    IntOp $ShortcutMode $0 - 6 ; Map .ini Field Id to 0 (or empty), 1 or 2 
    Abort 
${EndIf} 
FunctionEnd 

Section 
${If} $ShortcutMode = 0 
    SetShellVarContext all 
${ElseIf} $ShortcutMode = 1 
    SetShellVarContext current 
${EndIf} 
... 
SectionEnd 

有這種設計的一個問題,SetShellVarContext current可能不會映射$ SMPROGRAMS正確STARTMENU文件夾,因爲UAC可與不同的管理員用戶提升的過程......