I kwnow how to retrieve the version of an exe using jscript, but I can't find any way to retrieve other info like "Company", "Internal name" or "Product name".
function version_of( file_name )
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f;
try {
f = fso.GetFile( file_name )
} catch( e ) {
throw new Error( e.number, "Error retrieving version of file ``" + file_name + "'': " + e.description );
}
var v = fso.GetFileVersion( f );
if ( !v ) {
throw new Error( 1, "File ``" + file_name + "'' has not got a version" );
}
return v;
}
WScript.Echo( version_of( "c:\\windows\\system32\\winver.exe" ) );
Maybe I will write my own COM object to do the job...
Staying with jscript, by compiling in JScript.NET you could get the info from System.Diagnostics.FileVersionInfo. You could then expose it via COM interop if you need to call it from Windows Scripting Host.
It seems that indexes for GetDetailsOf may differ for the same OS version. For instance, Helen's link reports that "Product name" should be at 270 index for Windows 7, but it's at 267 on my computer. Therefore property indexes are not reliable. Although I didn't do an extensive testing to prove that fact. Since we are targeting only a few languages in our products I've ended up with the following solution:
Extended file properties, such as company name or product name, can be obtained in scripts using the
GetDetailsOf
method of the ShellFolder
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:
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:
Note that you can use
GetDetailsOf(null, property_index)
to get locale-specific property names (this can be useful on non-English Windows versions):