Extended file properties, such as company name or product name, can be obtained in scripts using the GetDetailsOf
method of the Shell Folder
object. The method takes a zero-based index number associated with the extended property and returns the property value as a string. In general, GetDetailsOf
can be used to retrieve any type of information that can be displayed in the detailed Shell view (View -> Choose Details). See Retrieving Extended File Properties.
The only problem is that different Windows versions offer different sets of extended file properties. For example, Windows XP has 34 file properties, Windows Vista — 266, Windows 7 — 284. Not only the property indexes can differ, but also the property names (Duration in Windows XP = Length in Windows Vista), which is quite confusing. For a full list of available file properties and their index numbers, see this page or use a script like this one:
var oShell = new ActiveXObject("Shell.Application");
var oFolder = oShell.Namespace("C:");
for (var i = 0; i < 300 /* some large number*/; i++)
WScript.Echo(i + " " + oFolder.GetDetailsOf(null, i));
Anyway, here's sample code to perform your task on Windows Vista. I couldn't find the Internal Name property (might not have searched properly) so included the File Version and Product Version instead:
var COMPANY_NAME = 33;
var FILE_VERSION = 145;
var PRODUCT_NAME = 251;
var PRODUCT_VERSION = 252;
var oShell = new ActiveXObject("Shell.Application");
var oFolder = oShell.Namespace("C:\Windows");
var oFile = oFolder.ParseName("notepad.exe");
WScript.Echo("Company name: " + oFolder.GetDetailsOf(oFile, COMPANY_NAME));
WScript.Echo("Product name: " + oFolder.GetDetailsOf(oFile, PRODUCT_NAME));
WScript.Echo("File version: " + oFolder.GetDetailsOf(oFile, FILE_VERSION));
WScript.Echo("Product version: " + oFolder.GetDetailsOf(oFile, PRODUCT_VERSION));
Note that you can use GetDetailsOf(null, property_index)
to get locale-specific property names (this can be useful on non-English Windows versions):
WScript.Echo(oFolder.GetDetailsOf(null, COMPANY_NAME) + ": " + oFolder.GetDetailsOf(oFile, COMPANY_NAME));
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…