1
我想为应用程序创建双安装程序,将其安装为便携式或普通版本。NSIS - 需要管理员权限
对于便携版本,我不想要求管理员权限。对于正常版本,我需要它们将应用程序添加到startmenu和其他东西。
开始实际安装时有没有办法提升管理员权限?也许有一个插件?类似于部分内部的“RequestExecutionLevel admin”。
谢谢!
我想为应用程序创建双安装程序,将其安装为便携式或普通版本。NSIS - 需要管理员权限
对于便携版本,我不想要求管理员权限。对于正常版本,我需要它们将应用程序添加到startmenu和其他东西。
开始实际安装时有没有办法提升管理员权限?也许有一个插件?类似于部分内部的“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
选择“最高”将迫使它来安装作为管理员,如果用户是admin。我认为最初的问题需要管理员在安装时可以选择是否需要系统安装。 – teeks99
最高将允许管理员用户选择。他们将被迫使用UAC升级,但非管理员安装应该正常工作。 – Anders