Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell WMIC Datafile Invalid Query?

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?

like image 380
PhoenixKsE Avatar asked Dec 11 '22 15:12

PhoenixKsE


1 Answers

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.

like image 77
PhoenixKsE Avatar answered Dec 24 '22 01:12

PhoenixKsE