繁体   English   中英

如何使用NSIS 3中的UAC_AsUser_ExecShell修复错误?

[英]How to fix errors with UAC_AsUser_ExecShell in NSIS 3?

在新版本3中,尝试使用适用于2.46 Unicode的NSI脚本,此行:

!insertmacro UAC_AsUser_ExecShell '' '$INSTDIR\test.exe' '--openbrowser' '' SW_SHOWNORMAL

产生以下错误:

!undef: "_UAC_ParseDefineFlags_orin_f2" not defined!
Error in macro _UAC_ParseDefineFlags_orin on macroline 12
Error in macro _UAC_ParseDefineFlags_Begin on macroline 6
Error in macro _UAC_ParseDefineFlagsToInt on macroline 1
Error in macro UAC_AsUser_Call on macroline 5
Error in macro UAC_AsUser_ExecShell on macroline 11
Error in script "c:\my.nsi" on line 308 -- aborting creation process

一年前有一个类似的未解决的问题

我的问题:

如何 NSIS 3中使用UAC插件

使用Wiki中的UAC插件v0.2.4c(20150526),我无法通过NSIS v3.01中的UAC_Basic.nsi的简单克隆来重现您的错误:

Unicode true
!addplugindir ".\plugins\x86-unicode" ; Only required if you have not copied the .dll

!define S_NAME "UAC minimal test ${NSIS_PACKEDVERSION}"

Name "${S_NAME}"
OutFile "${S_NAME}.exe"
RequestExecutionLevel user ; << Required, you cannot use admin!
InstallDir "$ProgramFiles\${S_NAME}"


!include UAC.nsh
!include MUI2.nsh

!macro Init thing
uac_tryagain:
!insertmacro UAC_RunElevated
${Switch} $0
${Case} 0
    ${IfThen} $1 = 1 ${|} Quit ${|} ;we are the outer process, the inner process has done its work, we are done
    ${IfThen} $3 <> 0 ${|} ${Break} ${|} ;we are admin, let the show go on
    ${If} $1 = 3 ;RunAs completed successfully, but with a non-admin user
        MessageBox mb_YesNo|mb_IconExclamation|mb_TopMost|mb_SetForeground "This ${thing} requires admin privileges, try again" /SD IDNO IDYES uac_tryagain IDNO 0
    ${EndIf}
    ;fall-through and die
${Case} 1223
    MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "This ${thing} requires admin privileges, aborting!"
    Quit
${Case} 1062
    MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Logon service not running, aborting!"
    Quit
${Default}
    MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Unable to elevate , error $0"
    Quit
${EndSwitch}

SetShellVarContext all
!macroend

Function .onInit
!insertmacro Init "installer"
FunctionEnd


!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_FUNCTION PageFinishRun
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_LANGUAGE "English"

Section
SectionEnd


Function PageFinishRun
!insertmacro UAC_AsUser_ExecShell '' '$WinDir\notepad.exe' '--openbrowser' '' SW_SHOWNORMAL
FunctionEnd

挖掘旧线程:

我有同样的问题,与我在NSIS 2.x上使用的版本相比,Wiki上的UAC插件有一个很小的变化。

小小的改变解决了这个问题

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM