I have searched and searched, but cannot figure out why this is returning an Invalid query error:
wmic datafile where name='c:\\program files (x86)\\Mozilla Firefox\\Firefox.exe' get version
I've tried it with an elevated PS as well, thinking that perhaps it was due to the permissions on the program files folders. I also tried it with case-sensitive path/filename. I've tried double quotes as well as single quotes, as well as no quotes. I've also tried replacing the double \'s with singles. I've even tried different files in different folder locations (like c:\temp); it seems that every time I use datafile where name, I get an invalid query, even if I leave off get version...
What in the world is going on?
Totally just found the answer. The entire name='path\filename.exe' needs to be in quotes... for some unknown reason.
like this:
wmic datafile where "name='c:\\program files (x86)\\Mozilla Firefox\\Firefox.exe'" get version
This then returns:
Version 31.0.0.5310
This is almost exactly what I need... now I just have to find a way to strip out the "Version" part of the returned value.
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