I'm attempting to get the owner of a file in Node.js on Windows. In the absence of a win32api, I thought I'd use a PowerShell command:
powershell -Command "(get-acl test.txt).owner"
This works perfectly from the command-line and from a batch file, but just hangs with Node.js exec()
:
var exec = require('child_process').exec;
exec('powershell -Command "(get-acl test.txt).owner"', function(err,sysout,syserr) {
console.dir(sysout);
});
The PowerShell process just appears to start and never terminate.
Does anybody have:
When you are calling Powershell like that you need to the close the input stream. You may want to try using spawn and use stdin.end()
.
Other option is to call cmd /c dir /q <file>
but that output is verbose.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With