endodave
(Starting to like KiXtart)
2008-03-27 07:41 PM
Determine version of MS Office installed

I'm trying to get an idea for who in the office is running something less than MS Office 2003. Is there a reg key or something I can query to determine not only the version of Office running on the client, but the service pack level? Thanks!

Glenn BarnasAdministrator
(KiX Supporter)
2008-03-27 08:09 PM
Re: Determine version of MS Office installed

Have you searched the UDF library? I seem to recall Doc posting something along these lines a while back.

Glenn


NTDOCAdministrator
(KiX Master)
2008-03-27 11:17 PM
Re: Determine version of MS Office installed

Yep, posted a couple of them.

This is probably the one you would want.
GetOfficeDetails2()

This is the main page for the UDFs where you can find over 600 pre-written script functions.

UDF Library


Witto
(MM club member)
2008-03-28 10:00 AM
Re: Determine version of MS Office installed

If you want to do it yourself
  • Recurse through "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
  • Find all the Data for the Value names "DisplayName"
  • Look with InStr() for "Microsoft Office"
  • If found, get the Values you need (p.e. the DisplayName and the DisplayVersion)


endodave
(Starting to like KiXtart)
2008-03-28 03:46 PM
Re: Determine version of MS Office installed

okay, i like that method. can you remind me how i "recurse" through that key to make the match on Microsoft Office in the Display Name field and then to also return the DisplayVersion? thanks.

endodave
(Starting to like KiXtart)
2008-03-28 04:15 PM
Re: Determine version of MS Office installed

or, using the function, this is what i am doing and it is not working:

Dim $MSO_Ver
$MSO_Ver = GetOfficeDetails2()
$rc Open (9, "\\servershare\Office_Versions.csv", 5)
$rc = writeline (9, @TIME + "," + @DATE + "," + @WKSTA + "," + @USERID + "," + @fullname + "," + $MSO_Ver + @CRLF)
$rc = close(9)

it's telling me "this type of array not supported in expressions." any idea?


endodave
(Starting to like KiXtart)
2008-03-28 04:24 PM
Re: Determine version of MS Office installed

okay, i was able to get it to output to the screen by this:

for each $item in GetOfficeDetails2()
? $item
next

however, the output is this:

10.0.6789.0
10.0.6802.0
10.0.6819.0
10.0.6771.0



10.0.6615.0

Microsoft Office XP Professional

What does all that mean?


Witto
(MM club member)
2008-03-28 05:56 PM
Re: Determine version of MS Office installed

;*************************************************************************
; Script Name: FindUninstallStrings.kix
; Author: Wim Rotty
; Date: 28/03/2008
; Description: Find the Uninstall Strings containing "Microsoft Office"
;************************************************************************* 


;Script Options
If
Not @LOGONMODE
    Break On
Else
    Break Off
EndIf
Dim $RC
;$RC = SetOption("Explicit", "On")
$RC
= SetOption("NoMacrosInStrings", "On")
$RC = SetOption("NoVarsInStrings", "On")
If @SCRIPTEXE = "KIX32.EXE"
    $RC = SetOption("WrapAtEOL", "On")
EndIf

;Declare variables
Dim $UninstallKey, $Count, $Key, $Value

;Initialize variables
$UninstallKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
$Count = 0

;Code
$Key = EnumKey($Uninstallkey, $Count)
While @ERROR = 0
   
;? $Key
    $Value = ReadValue($Uninstallkey+'\'+$Key,"DisplayName")
   
If InSTR($Value, "Microsoft Office")
        ?
$Value
        ? ReadValue($Uninstallkey+'\'+$Key,"DisplayVersion")
        ?
   
EndIf
    $Count = $Count + 1
   
$Key = EnumKey($Uninstallkey, $Count)
Loop

;Personal UDF Section

;UDF Section


endodave
(Starting to like KiXtart)
2008-03-28 07:30 PM
Re: Determine version of MS Office installed

this works beautifully. thanks!

endodave
(Starting to like KiXtart)
2009-05-08 10:06 PM
Re: Determine version of MS Office installed

so, while this works great, i'm now trying to exclude a workstation from running this portion of the script. Here's how I'm doing it and it's not working. Any idea?

 Code:
IF WKSTA <> name

Dim $RC
;$RC = SetOption("Explicit", "On")
$RC = SetOption("NoMacrosInStrings", "On")
$RC = SetOption("NoVarsInStrings", "On")
If @SCRIPTEXE = "KIX32.EXE"
    $RC = SetOption("WrapAtEOL", "On")
EndIf

;Declare variables
Dim $UninstallKey, $Count, $Key, $Value

;Initialize variables
$UninstallKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
$Count = 0

;Code
$Key = EnumKey($Uninstallkey, $Count)
While @ERROR = 0
    ;? $Key
    $DispName = ReadValue($Uninstallkey+'\'+$Key,"DisplayName")
    $DispVer = ReadValue($Uninstallkey+'\'+$Key,"DisplayVersion")
    If InSTR($DispName, "Microsoft Office")
        $rc = Open (9, "\\irvineefa01\kixtart_log\Office_Versions.csv", 5)
        $rc = writeline (9, @TIME + "," + @DATE + "," + @WKSTA + "," + @USERID + "," + @fullname + "," + $DispName + "," + $DispVer + "," + $item + @CRLF)
        $rc = close(9)
    EndIf
    $Count = $Count + 1
    $Key = EnumKey($Uninstallkey, $Count)
Loop
ENDIF


Gargoyle
(MM club member)
2009-05-09 06:43 AM
Re: Determine version of MS Office installed

1. Learn to use the code tags. Makes your code much easier to read.
2. Your IF statement is wrong.
IF @WKSTA <> "name"


Glenn BarnasAdministrator
(KiX Supporter)
2009-05-09 03:34 PM
Re: Determine version of MS Office installed

You could also experience a problem with your WriteLine if items such as "@FULLNAME" contains a comma. You should use a "real" CSV format, which detects any data that contains commas and encloses them in quotes. Look for the CSV function, which translates between an array of data and a CSV formatted string. Using it, you can do something like
 Code:
$CSVarray = @TIME, @DATE, @WKSTA, @USERID, @fullname, $DispName, $DispVer, $item
$Rc = WriteLine(9, CSV($CSVarray) + @CRLF)

Glenn


endodave
(Starting to like KiXtart)
2009-05-11 10:48 PM
Re: Determine version of MS Office installed

hi, i put the workstation name in quotes (IF @WKSTA <> "name"), but it is still being included.

Richard H.Administrator
(KiX Supporter)
2009-05-12 09:24 AM
Re: Determine version of MS Office installed

 Originally Posted By: endodave
hi, i put the workstation name in quotes (IF @WKSTA <> "name"), but it is still being included.


Did you also put the "@" in front of WKSTA? It is missing in the code that you posted above.


endodave
(Starting to like KiXtart)
2009-05-12 06:03 PM
Re: Determine version of MS Office installed

here is the code copied from the kix file:
 Code:
IF @WKSTA <> "DWF5Q8101C20"

Dim $RC
;$RC = SetOption("Explicit", "On")
$RC = SetOption("NoMacrosInStrings", "On")
$RC = SetOption("NoVarsInStrings", "On")
If @SCRIPTEXE = "KIX32.EXE"
    $RC = SetOption("WrapAtEOL", "On")
EndIf

;Declare variables
Dim $UninstallKey, $Count, $Key, $Value

;Initialize variables
$UninstallKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
$Count = 0

;Code
$Key = EnumKey($Uninstallkey, $Count)
While @ERROR = 0
    ;? $Key
    $DispName = ReadValue($Uninstallkey+'\'+$Key,"DisplayName")
    $DispVer = ReadValue($Uninstallkey+'\'+$Key,"DisplayVersion")
    If InSTR($DispName, "Microsoft Office")
        $rc = Open (9, "\\irvineefa01\kixtart_log\Office_Versions.csv", 5)
        $rc = writeline (9, @TIME + "," + @DATE + "," + @WKSTA + "," + @USERID + "," + @fullname + "," + $DispName + "," + $DispVer + "," + $item + @CRLF)
        $rc = close(9)
    EndIf
    $Count = $Count + 1
    $Key = EnumKey($Uninstallkey, $Count)
Loop

;;;;;;;;;;;;;
;	    ;
;    End    ;
;	    ;
;;;;;;;;;;;;;

ENDIF


Benny69
(MM club member)
2009-05-12 07:14 PM
Re: Determine version of MS Office installed

Hi endodave

When you post code please place that code in code tags, here is a link that will help you with that, The Post/Reply Formatting Box and How to use it


Radimus
(KiX Supporter)
2009-06-23 05:43 PM
Re: Determine version of MS Office installed

Here is another, but it returns more data than I want...

Can I do a WHERE clause that contains OR?? Where Name="this" or name="that"?

 Code:
$objWMI = GetObject("winmgmts:\\.\root\CIMV2")
$colItems = $objWMI.ExecQuery("SELECT * FROM Win32_Product WHERE Name Like 'Microsoft Office%'")
        
For Each $objItem In $colItems
        ? '1 '+ $objItem.Name
        ? '2 '+ $objItem.InstallLocation
        ? '3 '+ $objItem.Version
        ? '4 '+ $objItem.IdentifyingNumber
	?
    Next


Richard H.Administrator
(KiX Supporter)
2009-06-24 09:35 AM
Re: Determine version of MS Office installed

 Originally Posted By: Radimus
Here is another, but it returns more data than I want...

Can I do a WHERE clause that contains OR?? Where Name="this" or name="that"


Eh? Using an OR is going to return more results, not less

Anyway, a simple OR syntax is pretty much what you would expect:
 Code:
$objWMI = GetObject("winmgmts:\\.\root\CIMV2")

$colItems = $objWMI.ExecQuery("SELECT * FROM Win32_Product"
	+" WHERE Name Like 'Microsoft Office Visio Professional%'"
	+" OR Name Like 'Microsoft Office Professional%'"
	)
        
For Each $objItem In $colItems
	'1 '+ $objItem.Name+@CRLF
	'2 '+ $objItem.InstallLocation+@CRLF
	'3 '+ $objItem.Version+@CRLF
	'4 '+ $objItem.IdentifyingNumber+@CRLF
	@CRLF
Next


Radimus
(KiX Supporter)
2009-06-24 03:44 PM
Re: Determine version of MS Office installed

I wound up doing this:

 Code:
? @time

$objWMI = GetObject("winmgmts:\\.\root\CIMV2")
$colItems = $objWMI.ExecQuery("SELECT * FROM Win32_Product WHERE Name='Microsoft Office Enterprise 2007' or Name='Microsoft Office Professional Plus 2007'")
        
For Each $objItem In $colItems
        ? '1 '+ $objItem.Name
        ? '2 '+ $objItem.InstallLocation
        ? '3 '+ $objItem.Version
        ? '4 '+ $objItem.IdentifyingNumber
	?
    Next

? @time

	$MSOKey  = iif(keyexist("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{90120000-0030-0000-0000-0000000FF1CE}"),'{90120000-0030-0000-0000-0000000FF1CE}','{90120000-0011-0000-0000-0000000FF1CE}') 
	$MSOType = readvalue("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"+$MSOKey,"DisplayName")
	$MSOdir	 = readvalue("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"+$MSOKey,"InstallLocation")
	$MSOVer  = readvalue("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"+$MSOKey,"DisplayVersion")
	$MSOMajor= Split($MSOVer,'.')[0]
	$MSOMinor= Split($MSOVer,'.')[2]
?
? $MSOType 
? $MSOdir	 
? $MSOver
? $MSOMajor
? $MSOMinor
?
? @time
?
? 'press enter to end'
gets $k


NTDOCAdministrator
(KiX Master)
2009-06-26 12:52 AM
Re: Determine version of MS Office installed

Well WMI is pig slow, but going forward with Vista and Windows 7 it sure seems like we're going to be stuck using them to get past the security of the OS to do scripting.

KIXKicks
(Starting to like KiXtart)
2009-07-16 02:56 PM
Re: Determine version of MS Office installed

Endodave,

Here is some code that may help exclude the one computer from this script. Change it as needed...

 Code:
$COMPUTERNAME=@HOSTNAME

IF $COMPUTERNAME="BURRITO" OR $COMPUTERNAME="BURRITO.DOMAIN.DOM"
	$MSINTERNETEXPLORERSPSTATUS="VALID"
ENDIF