Gab*_*ich 5 file-properties node.js node-webkit
我正在使用NWJS开发桌面应用程序,我需要获取.exe文件的文件属性.
我已经尝试使用npm属性模块https://github.com/gagle/node-properties,但我得到一个空的Object.
properties.parse('./unzipped/File.exe', { path: true }, function (err, obj) {
if (err) {
console.log(err);
}
console.log(obj);
});
Run Code Online (Sandbox Code Playgroud)
我需要获取"文件版本"属性:

我也试过使用fs.stats而没有运气.有任何想法吗?
除非您想编写一些本机 C 模块,否则有一种简单的方法可以轻松完成此操作:使用 windowswmic命令。这是获取版本的命令(通过谷歌搜索找到):
wmic datafile where name='c:\\windows\\system32\\notepad.exe' get Version
Run Code Online (Sandbox Code Playgroud)
因此,您只需在节点中运行此命令即可完成工作:
var exec = require('child_process').exec
exec('wmic datafile where name="c:\\\\windows\\\\system32\\\\notepad.exe" get Version', function(err,stdout, stderr){
if(!err){
console.log(stdout)// parse this string for version
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4157 次 |
| 最近记录: |