tjd*_*ett 8 javascript windows powershell node.js
我试图在Windows上获取Node.js中文件的所有者.在没有win32api的情况下,我想我会使用PowerShell命令:
powershell -Command "(get-acl test.txt).owner"
Run Code Online (Sandbox Code Playgroud)
这可以从命令行和批处理文件中完美地工作,但只是挂起Node.js exec():
var exec = require('child_process').exec;
exec('powershell -Command "(get-acl test.txt).owner"', function(err,sysout,syserr) {
console.dir(sysout);
});
Run Code Online (Sandbox Code Playgroud)
PowerShell进程似乎刚开始并且永不终止.
有人有:
当您像这样调用Powershell时,您需要关闭输入流.您可能想尝试使用spawn并使用它stdin.end().
其他选项是调用,cmd /c dir /q <file>但输出是详细的.
| 归档时间: |
|
| 查看次数: |
3738 次 |
| 最近记录: |