How Can I Determine Which Version of Word is Installed on a Computer?

ScriptingGuy1

Hey, Scripting Guy! Question

Hey, Scripting Guy! How can I determine which version of Word is installed on a computer?

— RR

SpacerHey, Scripting Guy! AnswerScript Center

Hey, RR. Turns out that this is a trickier question than you might expect. That’s because WMI does only a so-so job of retrieving information about the software installed on a computer. In theory, you can use a script like this one to get back version information for Microsoft Office:

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

So why not just use that script? Well, two reasons. First, this script uses the Like operator; that operator is available only on Windows XP and Windows 2003. (And, just to complicate things, the Win32_Product class is not installed by default on Windows 2003.) If you’re still running Windows 2000, you’re out of luck. Instead, the best you could do is retrieve all the instances of the Win32_Product class, then check each instance to see if the caption includes the term Microsoft Office.

Second, the preceding query returns information for any piece of software that has the term Microsoft Office somewhere in its name. You’ll get the scoop on Microsoft Office Professional Edition 2003 all right, but you’ll also get back information for applications like Microsoft Producer for Microsoft Office PowerPoint 2003. Consequently, you might have to further modify this script to ensure that you get back only information about the “real” Microsoft Office.

And before you ask: yes, version information is stored in the registry, but, sadly, it’s not always clear where in the registry to get this information. The location depends on the version of Office installed on a machine, as well as whether this was a clean install or an upgrade of an earlier version of Office. Which means that querying the registry to find out what version of Word is installed on a computer can also be a bit tricky, particularly in organizations where you are likely to have computers running different versions of Office.

So then how the heck do you determine the version of Word installed on a computer? Well, after giving it a bit of thought, we decided the best way was to just ask Word. Here’s a script that creates an instance of Microsoft Word, echoes back the version and build numbers, and then terminates that instance of Word:

Set objWord = CreateObject(“Word.Application”)
Wscript.Echo “Version: ” & objWord.Version
Wscript.Echo “Build: ” & objWord.Build
objWord.Quit

Four little lines of code, and pretty much guaranteed to work. On top of that, the instance of Word you create runs in an invisible window, so you won’t even see Word pop up on the screen. What more could you ask for?

If you want to find out the version of Word installed on a remote computer, just add that computer name as the optional second parameter passed to CreateObject. This modified script grabs the version of Word installed on the remote computer atl-ws-01:

Set objWord = CreateObject(“Word.Application”, “atl-ws-01”)
Wscript.Echo “Version: ” & objWord.Version
Wscript.Echo “Build: ” & objWord.Build
objWord.Quit

Sure, it might seem like overkill, but ultimately this approach should prove easier and more reliable than using Win32_Product or trying to grab version information from the registry.

0 comments

Discussion is closed.

Feedback usabilla icon