简体   繁体   English

在节点 js 中使用管理员权限运行 exe

[英]Run exe with admin perms in node js

I want to start an exe-file as admin with node.我想以管理员身份使用节点启动一个 exe 文件。 Tried something like this, but this dont want to work:尝试过这样的事情,但这不想工作:

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

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

Any Ideas?有任何想法吗?

According to the documentation of runas you should include the ComputerName like this:根据runas文档,您应该像这样包含 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

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

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