2014-09-10 42 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可与不同的管理员用户提升的过程......