Forum Discussion

vinodkumar_chau's avatar
vinodkumar_chau
Contributor
11 years ago

How to get MS Office version installed on the machine

Hi Team ,

 

How to get MS Office version (Not excel or word) installed on the machine  using Jscript?

 

var ProgramFiles = aqEnvironment.GetEnvironmentVariable("ProgramFiles", true);
var MSOffFilePath = ProgramFiles +"\\Microsoft Office\\Office14\\EXCEL.EXE"; 
var Officeversion = aqFileSystem.GetFileInfo(MSOffFilePath).VersionInfo.FileMajorVersion;
Log.Message(Officeversion);

1 Reply

  • Think about what you are asking and you will find that you have more or less answered your own question. Simply put, the the product name is really dependent on the values for the version numbers of the executables for Access, Excel, PowerPoint, Word, etc.

     

    MS_Access_Exe_Details.jpg

     

    That siad, according to theMS article Application Registration, you should be able to find the application executable under the key:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths

     

    Problem is at this point we are unsure of the what the MS Office executable is, so a quick search of the registry for 'office 2010' and one of the results pointed me to ois.exe (C:\PROGRA~2\MICROS~2\Office14\OIS.EXE) but as you can see in the screen shot below, the only thing that identifies this as Office 2010 is the 'Product Name' and 'Description' attributes of the file:

     

    MS_Office_OIS_Exe_Details.jpg

     

    To iterate extended file attributes, use Shell.Applicaiton to bind to the files parent folder, then the file to get a list of the extended file attributes:

     

     

    GetFileDetails "C:\Program Files (x86)\Microsoft Office\Office14", "OIS.EXE"
    
    Sub GetFileDetails(sFilePath, sFileName)
       
       Dim shell : Set shell = CreateObject("Shell.Application")
       Dim arrHeaders(34), fileInfo, folder, folderItem, i
       
       Set folder = shell.Namespace(sFilePath)
       Set folderItem = folder.ParseName(sFileName)
       
       If (Not folder Is Nothing) Then
          For i = 0 To 34
             arrHeaders(i) = folder.GetDetailsOf(folder.Items, i)
          Next
          
          Set folderItem = folder.ParseName(sFileName)
          
          If (Not folderItem Is Nothing) then
             For i = 0 To 34        
                fileInfo = folder.GetDetailsOf(folderItem, i)
                
                If aqString.GetLength(fileInfo) > 0 Then
                   Log.Message arrHeaders(i) & ":" fileInfo
                End If
             Next
          End If
                
          Set folderItem = Nothing
       End If
    
       Set shell = Nothing
    
    End Sub