我想为应用程序创建一个双重安装程序,将其安装为便携式或普通版本。
对于便携式版本,我不想要求管理员权限。对于普通版本,我需要管理员权限才能将应用程序添加到开始菜单和其他内容。
有没有办法在开始实际安装时提示用户提供管理员权限?也许有插件?我正在寻找类似RequestExecutionLevel admin
部分内部的东西。
我想为应用程序创建一个双重安装程序,将其安装为便携式或普通版本。
对于便携式版本,我不想要求管理员权限。对于普通版本,我需要管理员权限才能将应用程序添加到开始菜单和其他内容。
有没有办法在开始实际安装时提示用户提供管理员权限?也许有插件?我正在寻找类似RequestExecutionLevel admin
部分内部的东西。
RequestExecutionLevel highest
将强制管理员组的成员提升,而普通用户可以在没有 UAC 交互的情况下运行它。此示例对您没有帮助,因为这样做很棘手,UAC 在某些情况下会被破坏,并且需要更多代码才能正确执行...
RequestExecutionLevel highest
Var InstMode
!include nsDialogs.nsh
!include Sections.nsh
!include LogicLib.nsh
Page Custom InstallModePageInit InstallModePageLeave
Page InstFiles
Section "StartMenu shortcuts" SEC_SM
; CreateShortcut ...
SectionEnd
Section "" SEC_UNINST
; WriteUninstaller & registry
SectionEnd
Function InstallModePageInit
nsDialogs::Create 1018
Pop $0
${NSD_CreateRadioButton} 20u 30u 100% 12u "Normal install"
Pop $1
${NSD_CreateRadioButton} 20u 50u 100% 12u "Portable install"
Pop $2
${If} $InstMode = 0
${NSD_Check} $1
${Else}
${NSD_Check} $2
${EndIf}
nsDialogs::Show
FunctionEnd
Function InstallModePageLeave
${NSD_GetState} $2 $InstMode
${If} $InstMode = 0
!insertmacro SelectSection ${SEC_SM}
!insertmacro SelectSection ${SEC_UNINST}
UserInfo::GetAccountType
Pop $0
${If} $0 != "Admin"
MessageBox mb_iconstop "Administrator privileges required, please restart installer to continue..."
Abort
${EndIf}
${Else}
!insertmacro UnselectSection ${SEC_SM}
!insertmacro UnselectSection ${SEC_UNINST}
${EndIf}
FunctionEnd