views:

338

answers:

2

Hi, 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...

+1  A: 

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.

import System.Diagnostics;

private function GetCompanyName(filename) {
    return FileVersionInfo.GetVersionInfo(filename).CompanyName;
 }

 private function GetInternalName(filename) {
    return FileVersionInfo.GetVersionInfo(filename).InternalName;
 }

private function GetProductName(filename) {
    return FileVersionInfo.GetVersionInfo(filename).ProductName;
}
machine elf
+2  A: 
Helen
thank you very much!You are the best.
uvts_cvs