Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Script to check for version of Office

45 views
Skip to first unread message

Jeff

unread,
Nov 18, 2003, 4:07:29 PM11/18/03
to
How would I write a script to check for the version of office installed on a
PC? I thought about querying WMI to get the info from Win32_Product. But I
don't know how to go from there.

Thanks,

Jeff


Torgeir Bakken (MVP)

unread,
Nov 18, 2003, 4:29:46 PM11/18/03
to
Jeff wrote:

Hi

You can do it with e.g. some registry reads:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=uZaiTKcqDHA.2636%40TK2MSFTNGP09.phx.gbl

--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter


Dave Patrick

unread,
Nov 18, 2003, 4:31:34 PM11/18/03
to
Something along this line may work. Assumes multiple versions not installed.

Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")

Select Case WshShell.RegRead("HKCR\.mdb\")
Case "Access.Application.8"
Msgbox "Access 97"
Case "Access.Application.9"
Msgbox "Access 2000"
Case "Access.Application.10"
Msgbox "Access XP"
Case "Access.Application.11"
Msgbox "Access 2003"
Case Else
Msgbox "Access not installed"
End Select
Set WshShell = Nothing


--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft MVP [Windows NT/2000 Operating Systems]

Jeff

unread,
Nov 19, 2003, 8:58:26 AM11/19/03
to
Thanks, Torgeir. That helps. One follow up question: Will the script in
the posting belo work for remote computers? I'd like to be able to run the
script against the PCs at our site.

Thanks,

Jeff

"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message
news:3FBA8F4A...@hydro.com...

Torgeir Bakken (MVP)

unread,
Nov 19, 2003, 11:16:14 AM11/19/03
to
Jeff wrote:

> Thanks, Torgeir. That helps. One follow up question: Will the script in
> the posting belo work for remote computers? I'd like to be able to run the
> script against the PCs at our site.

Hi

No, not like the way it is now, the Regreads needs to be changed to use WMI's Standard Registry Provider (see
below).

One issue with WMI is that if the remote computer is offline by some reason, the timeout for the WMI connection
is pretty long.

If you run your script from a WinXP computer, I think there is a way to set the
timeout for the WMI connection. If you run this from a Win2k (or WinXP)
computer, you could ping the computer before you connect to it to see if it is
online.

The VBScript function IsConnectible in the link below will work on all OS
versions (it uses ping.exe to ping the host to see if it is online):

http://groups.google.com/groups?selm=3EB2AA54.EBB5ECBC%40hydro.com


Here is a suggestion for a WMI version of the GetOfficeVer function:


sComputer = "some ip or computer name here" ' use "." for local computer
iOfficeVer = GetOfficeVer(sComputer)

If iOfficeVer = -1 Then
WScript.Echo "Version of Office installed is unknown, " _
& "could not connect to the remote computer."
Elseif iOfficeVer = 0 Then
WScript.Echo "Office is not installed."
Else
WScript.Echo "Version of Office installed: " & iOfficeVer
End If


Function GetOfficeVer(sNode)
On Error Resume Next
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& sNode & "/root/default:StdRegProv")
If Err.Number <> 0 Then
GetOfficeVer = -1
Exit Function '------->
End If

sValueName = "Path"
sRegPre = "SOFTWARE\Microsoft\Office\"
sRegPost = "\Common\InstallRoot"

If oReg.GetStringValue( _
HKLM, sRegPre & "11.0" & sRegPost, sValueName, sValue) = 0 Then
GetOfficeVer = 2003
Elseif oReg.GetStringValue( _
HKLM, sRegPre & "10.0" & sRegPost, sValueName, sValue) = 0 Then
GetOfficeVer = 2002
Elseif oReg.GetStringValue( _
HKLM, sRegPre & "9.0" & sRegPost, sValueName, sValue) = 0 Then
GetOfficeVer = 2000
Elseif oReg.GetStringValue( _
HKLM, sRegPre & "8.0" & sRegPost, sValueName, sValue) = 0 Then
GetOfficeVer = 97
Else
GetOfficeVer = 0
End If

End Function

0 new messages