Search code examples
javascriptnode.jschild-processexecute

Run exe with admin perms in node js


I want to start an exe-file as admin with node. 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"

Any Ideas?


Solution

  • According to the documentation of runas you should include the ComputerName like this:

    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