Check office 2007 version

supportservices
supportservices used Ask the Experts™
on
I need to run a script that will check all domain PC's.  I am looking check the Key and output the LastProduct info to csv file....  

See: ****Where I get lost!******* in the script....

Key I need to output to file with PC name and Office Version.  
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Common\ProductVersion]
"LastProduct"="12.0.6425.1000"





'This Script will scan the network and return LastProduct from Registry.  
'*********************************
'Start Script
'*********************************

'******Declares********
Dim Computers, i
Dim FSObject, FileObject, BaseLineFile

'On error resume next

Set FSObject = CreateObject("Scripting.FileSystemObject")

'Get Computer names from XYZ Domain
Computers = GetComputerNames("XYZ")

'Create Text File
Set FileObject = FSObject.CreateTextFile("c:\XYZ\Office2007Version.csv", True)

For i = 0 To Ubound(Computers)
'Ping machine
If CheckComputerConnection(Computers(i)) = True Then


****Where I get lost!*******
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Common\ProductVersion]
"LastProduct"="12.0.6425.1000"
******************************


Then
'Write to csv files
FileObject.WriteLine Computers(i)
End if
End if
Next

MsgBox "Complete"

'*********************************
'End Script
'*********************************

'*********************************Functions*****************************

'*********************************
'Function GetComputerNames
'*********************************
Function GetComputerNames(DomainName)
'This function will be used to get a list of computer names in a specified Domain.
On error Resume Next
Dim Computers
Dim ObjComputers
Dim ComputerNames()
Dim i

'Get List of computers from domain
Set Computers = GetObject("WinNT://" & DomainName)
'Run Filter to just return computer objects
Computers.Filter = Array("Computer")

'Loop Through Computer Object and get their names.
For Each ObjComputers In Computers
ReDim Preserve ComputerNames(i)
'Add Computer Names to Array
ComputerNames(i) = ObjComputers.Name
i = i + 1
Next

'Empty Objects
Set Computers = Nothing
Set ObjComputers = Nothing

'Return the array of computer Names.
GetComputerNames = ComputerNames
End Function

'*********************************
'Function CheckComputerConnection
'*********************************
Function CheckComputerConnection(ComputerName)
'This function will check to see if the PC can be reached.
'on error resume next
'Before connecting to the computer, use ping to see if you get a response.
'A WMI connection attempt is not used because WMI's connection timeout interval
'is too long
Dim objExec
Dim objShell
Dim strPingStdOut

Set objShell = CreateObject("WScript.Shell")

Set objExec = objShell.Exec("ping -n 2 -w 1000 " & ComputerName)
strPingStdOut = LCase(objExec.StdOut.ReadAll)

'Test whether ping was successful
If InStr(Lcase(strPingStdOut), "reply from ") Then
CheckComputerConnection = True
Else
CheckComputerConnection = False
End if

End Function
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Is this what you need, to get the data out of the registry?
sew

Set WshShell = WScript.CreateObject("WScript.Shell")
value = WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Office\12.0\Common\ProductVersion\LastProduct")
msgbox value

Open in new window

Author

Commented:
Yes that would be the correct output when I ran it on an XP PC that has that key. Although when I tried on Windows 7 that path does not exist so I received an error.  
Not sure where the registry entry is for Office in Windows 7. One option is to check MS Word's version when the system is Windows 7.

Not sure if this helps...
sew

If InStr(GetWindowsVersion(), "Windows 7") > 0 Then
	Set objWord = CreateObject("Word.Application")
	wscript.echo objWord.Build
Else
	Set WshShell = WScript.CreateObject("WScript.Shell")
	value = WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Office\12.0\Common\ProductVersion\LastProduct")
	msgbox value 
End If


Function GetWindowsVersion()
	Dim objShell, strOS, strVerKey, strVersion
	Set objShell = CreateObject("WScript.Shell")
	strOS = objShell.ExpandEnvironmentStrings("%OS%")

	If strOS = "Windows_NT" Then
	   strVerKey = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\"
	   strVersion = objShell.RegRead(strVerKey & "ProductName") & " " & objShell.RegRead(strVerKey & "CurrentVersion") & "." & objShell.RegRead(strVerkey & "CurrentBuildNumber")
	Else
	  strVerKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\"
	  strVersion = objShell.RegRead(strVerKey & "ProductName") & " " & objShell.RegRead(strVerKey & "VersionNumber")
	End if
	GetWindowsVersion = strVersion

	Set objShell = Nothing
End Function

Open in new window

Author

Commented:
As far as working on Windows 7 that works for me.  Just need to figure out how I can get this to work in my script to run on domain and output data to a txt or csv file.

Author

Commented:
This was only a partial solution to the question.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial