Node JS - read file properties

I am developing a desktop application with NWJS and I need to get the properties of the .exe file.

I tried using the npm properties module https://github.com/gagle/node-properties , but I get an empty object.

properties.parse('./unzipped/File.exe', { path: true }, function (err, obj) {
            if (err) {
                console.log(err);
            }

            console.log(obj);
        });

I need to get the "File version" property:

File properties

I also tried using fs.stats and no luck. Any ideas?

+4
source share
1 answer

If you do not want to write any native C-module, there is a hacker way to do this easily: using the windows command wmic. This is the command to get the version (found using googling):

wmic datafile where name='c:\\windows\\system32\\notepad.exe' get Version

so you can just run this command in node to complete the task:

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
 }
});
+2
source

All Articles