I have app / executable file paths and I want to get the friendly app name from them. Imagine a getAppName
function like this:
const result = getAppName('C:\Program Files\Mozilla Firefox\firefox.exe');
console.log(result); // Firefox
For example, on Windows, if you right click the app and click "Properties", you can see this name in General > Description and Details > File Description;
I've had no luck looking for npm packages, system commands, etc. In the end, I need a solution for Linux, Mac, and Windows. Ideally there's a way via a built-in Node.js package or something on npm, but I might have to cobble together a solution usibe three OS-specific system commands I execute from Node.js.
I found WMIC (in How to check file properties through WMI command line) for Windows but I can't quite get what I want out of it;
wmic datafile where name="C:\Program Files\Mozilla Firefox\firefox.exe" get Description
Description
C:Program FilesMozilla Firefoxfirefox.exe
wmic datafile where name="C:\Program Files\Mozilla Firefox\firefox.exe" get Name
Name
C:Program FilesMozilla Firefoxfirefox.exe
wmic datafile where name="C:\Program Files\Mozilla Firefox\firefox.exe" get File Description
Invalid GET Expression.
wmic datafile where name="C:\Program Files\Mozilla Firefox\firefox.exe" get File Name
Invalid GET Expression.
wmic datafile where name="C:\Program Files\Mozilla Firefox\firefox.exe" get FileName
FileName
firefox
wmic datafile where name="C:\Program Files\Mozilla Firefox\firefox.exe" get FileDescription
Node - XPS
ERROR:
Description = Invalid query
wmic datafile where name="C:\Program Files\Mozilla Firefox\firefox.exe" get ProductName
Node - XPS
ERROR:
Description = Invalid query
wmic datafile where name="C:\Program Files\Mozilla Firefox\firefox.exe"
AccessMask Archive Caption Compressed CompressionMethod CreationClassName CreationDate CSCreationClassName CSName Description Drive EightDotThreeFileName Encrypted EncryptionMethod Extension FileName FileSize FileType FSCreationClassName FSName Hidden InstallDate InUseCount LastAccessed LastModified Manufacturer Name Path Readable Status System Version Writeable
1179817 TRUE C:Program FilesMozilla Firefoxfirefox.exe FALSE CIM_LogicalFile 20190906213704.287820+060 Win32_ComputerSystem XPS C:Program FilesMozilla Firefoxfirefox.exe c: c:program filesmozilla firefoxfirefox.exe FALSE exe firefox 576032 Application Win32_FileSystem NTFS FALSE 20190906213704.287820+060 20190907195815.492271+060 20190906213710.011611+060 Mozilla Corporation C:Program FilesMozilla Firefoxfirefox.exe program filesmozilla firefox TRUE OK FALSE 69.0.0.7178 TRUE
C:Usersadaml>wmic datafile where name="C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" get "file system name"
FSName
NTFS
C:Usersadaml>wmic datafile where name="C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" get "file system class name"
FSCreationClassName
Win32_FileSystem
I don't want to do anything like take the extension-less filename and capitalize the first character. I want the accurate/real name which is shown to users.
See Question&Answers more detail:
os