最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Elevate NodeJSElectron process on Windows - Stack Overflow

programmeradmin2浏览0评论

I'm currently building an app in Electron/NodeJS and am at a point where I'll need to elevate privileges on Windows to do a specific task (only Win7+ are a concern). How can I do this programmatically? I'll even take executing a bash script if it gets the job done. Thanks!

I'm currently building an app in Electron/NodeJS and am at a point where I'll need to elevate privileges on Windows to do a specific task (only Win7+ are a concern). How can I do this programmatically? I'll even take executing a bash script if it gets the job done. Thanks!

Share Improve this question edited Jul 23, 2015 at 14:04 Dustin asked Jul 23, 2015 at 12:56 DustinDustin 6,29719 gold badges63 silver badges93 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

In order to UAC elevate, use the runas module: https://www.npmjs./package/runas

I did some file writes using use node-powershell module :node-powershell

 const ps = new Shell({
    executionPolicy: 'Bypass',
    noProfile: true
});

ps.addCommand(`Start-Process -WindowStyle hidden cmd -Verb RunAs -ArgumentList '/c mkdir "C:\\Program Files\\foo"'`);
发布评论

评论列表(0)

  1. 暂无评论