运行 节点 js 中具有管理员权限的 exe

Run exe with admin perms in node js

我想以管理员身份使用 node.js 启动一个 exe 文件。试过这样的东西,但这不想工作:

exec('runas /user:Administrator "app.exe"', function(err, data) {  
                        console.log(err)                       
});

我总是收到此错误:Error: Command failed: runas /user:Administrator "app.exe"

有什么想法吗?

根据 runasdocumentation,您应该像这样包含 ComputerName:

If you want to use the Administrator account on your computer, for the /user: parameter, type one of the following:

**/user:<**AdministratorAccountName>@<ComputerName>

**/user:<ComputerName>\<**AdministratorAccountName>    <----- here