installation - 使用 NSIS 执行命令

标签 installation cmd nsis

我想使用 NSIS 脚本执行一些命令,但要使命令正常工作,我必须使用右键单击菜单中的“以管理员身份运行”打开命令提示符。它是如何使用 NSIS 脚本实现的。

我正在使用

 RequestExecutionLevel admin 

与 exec 命令一起使用,但这似乎不起作用。

最佳答案

RequestExecutionLevel 仅在 UAC 打开时适用于 Vista+,因此您还应该在运行时检查以涵盖其他情况:

Outfile RequireAdmin.exe
RequestExecutionLevel admin ;Require admin rights on NT6+ (When UAC is turned on)

!include LogicLib.nsh

Function .onInit
UserInfo::GetAccountType
pop $0
${If} $0 != "admin" ;Require admin rights on NT4+
    MessageBox mb_iconstop "Administrator rights required!"
    SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
    Quit
${EndIf}
FunctionEnd

Page InstFile

Section
SectionEnd

关于installation - 使用 NSIS 执行命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11049791/

相关文章:

visual-studio - 从 Visual Studio 安装程序项目安装 Windows 服务

php - 在 PHP 中使用 imap 函数而无需重建和重新安装

windows - 使用参数从 PowerShell 启动批处理文件

batch-file - 批量存储 ffprobe 作为变量

c++ - 有没有办法提前测试Windows exe是否会因为缺少dll而无法加载?

r - 无法访问R中的用户库- "Non-Zero Exit Status"警告

ubuntu - QEMU 未安装在 Ubuntu 中

java - 通过命令提示符运行的 JDBC Java 文件

installation - "URL Parts Error"inetc::post in nsis

text - 如何在 NSDialogs 中定义字体颜色