Reputation: 6307
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!
Upvotes: 8
Views: 5664
Reputation: 1014
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"'`);
Upvotes: 2
Reputation: 74692
In order to UAC elevate, use the runas
module: https://www.npmjs.com/package/runas
Upvotes: 5