Search code examples
node.jsspawn

In nodejs on windows, how do I use the `uid` option with child_process.spawn?


What I would like to do is to get the current users uid. I am exec'ing a process elevated and then I want to spawn another process with the original users uid again.

How do I get the current users uid on windows?

var child = spawn(process, args, {
    detached: true,
    uid: uid, // how do I get this on windows?
    cwd: appDir,
    stdio: [ 'ignore', 'pipe', 'pipe']
})

Solution

  • process.getuid() (SO requires at least 30 chars)