Determine Microsoft Office Version Via Script

I needed to determine which version of Microsoft Office was present on a group of Windows XP systems to determine which of the systems have the Microsoft Access database program on them. The "Professional" and "Premium" versions of Microsoft Office include Access, but the Small Business Edition does not. I didn't want to have to login to each system individually to make the determination, so I used a couple of VBScript scripts from Hey, Scripting Guy!.

At Hey, Scripting Guy! How Can I Determine Which Version of Word is Installed on a Computer?, there is a short script which can query Windows XP systems to determine which version of Microsoft Office is installed. That code only works with Windows XP systems and Windows 2003, if the Win32_Product class is installed, which is not installed on Windows 2003 by default. But, since all of the systems I needed to query are running Windows XP, that was sufficient for my purposes. There is code at that webpage that could be used to determine the version of Word on a system that will work for more Windows operating systems.


strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colApps = objWMIService.ExecQuery _
    ("Select * from Win32_Product Where Caption Like '%Microsoft Office%'")
For Each objApp in colApps
    Wscript.Echo objApp.Caption, objApp.Version
Next

The script, when run, will produce output similar to what is shown below, depending on what Microsoft software is installed on the system.


C:\Documents and Settings\Administrator>cscript /nologo office_version.vbs
Microsoft Office Outlook 2003 11.0.7969.0
Microsoft Office 2000 Professional 9.00.2720
Microsoft Office Visio Viewer 2003 (English) 11.0.3709.5614
Microsoft Office 2000 Disc 2 9.00.2720

But that script will check only the system on which it is run. I wanted to be able to check multiple systems without logging into each one to check. So I merged another script from Hey, Scripting Guy! with the above script. The How Can I Use Both Command-line Arguments and a Default Value? script allows one to specify none, one, or multiple systems as command line arguments to the script. That script displays only the operating system for systems against which it is run, so I merged the code from the above script with it to display the version of Microsoft Office for multiple systems.

The office_versions.vbs script can be run as cscript /nologo office_versions.vbs sysa sysb sysc to check the version of Microsoft Office on systems sysa, sysb, and sysc. Again, a limitation is that you can only be assured it will work when the systems queried are Windows XP systems, though.

The output for multiple systems will look similar to the following:


C:\Documents and Settings\Administrator>cscript /nologo office_versions.vbs b d
g j l u w
System: b OS: Microsoft Windows XP Professional

Microsoft Office Small Business Edition 2003 11.0.7969.0

System: d OS: Microsoft Windows XP Professional

Microsoft Office Small Business Edition 2003 11.0.7969.0

System: g OS: Microsoft Windows XP Professional

Microsoft Office 2000 Premium 9.00.2720
Microsoft Office Outlook 2003 11.0.5614.0

System: j OS: Microsoft Windows XP Professional

Microsoft Office Small Business Edition 2003 11.0.7969.0

System: l OS: Microsoft Windows XP Professional

Microsoft Office 2000 Premium 9.00.2720
Microsoft Office Outlook 2003 11.0.7969.0
Microsoft Office 2000 Disc 2 9.00.2720

System: u OS: Microsoft Windows XP Professional

Microsoft Office 2000 Premium 9.00.2720
Microsoft Office Outlook 2003 11.0.7969.0

System: w OS: Microsoft Windows XP Professional

Microsoft Office Small Business Accounting 2006 1.0.2912.2
Microsoft Office Small Business Edition 2003 11.0.7969.0
Microsoft Office Outlook 2003 with Business Contact Manager Update 2.0.4013.0

If no system is specified as an argument on the command line, the script will display "." as the computer name, as shown below:

C:\Documents and Settings\Administrator>cscript /nologo office_versions.vbs
System: . OS: Microsoft Windows XP Professional

Microsoft Office Outlook 2003 11.0.7969.0
Microsoft Office 2000 Professional 9.00.2720
Microsoft Office Visio Viewer 2003 (English) 11.0.3709.5614
Microsoft Office 2000 Disc 2 9.00.2720

Download
office_version.vbs Checks only current system
office_versions.vbs Can check multiple systems

References:

  1. Microsoft Office
    Wikipedia
  2. VBScript
    Wikipedia
  3. How Can I Determine Which Version of Word is Installed on a Computer?
    Microsoft TechNet
  4. How Can I Use Both Command-line Arguments and a Default Value?
    Microsoft TechNet

Valid HTML 4.01 Transitional

Created: Tuesday November 28, 2006