Page 1 of 2 12>
Topic Options
#186513 - 2008-03-27 07:41 PM Determine version of MS Office installed
endodave Offline
Starting to like KiXtart

Registered: 2005-08-17
Posts: 101
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!
Top
#186514 - 2008-03-27 08:09 PM Re: Determine version of MS Office installed [Re: endodave]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Have you searched the UDF library? I seem to recall Doc posting something along these lines a while back.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#186515 - 2008-03-27 11:17 PM Re: Determine version of MS Office installed [Re: Glenn Barnas]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
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

Top
#186518 - 2008-03-28 10:00 AM Re: Determine version of MS Office installed [Re: NTDOC]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
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)

Top
#186522 - 2008-03-28 03:46 PM Re: Determine version of MS Office installed [Re: Witto]
endodave Offline
Starting to like KiXtart

Registered: 2005-08-17
Posts: 101
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.
Top
#186524 - 2008-03-28 04:15 PM Re: Determine version of MS Office installed [Re: endodave]
endodave Offline
Starting to like KiXtart

Registered: 2005-08-17
Posts: 101
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?

Top
#186525 - 2008-03-28 04:24 PM Re: Determine version of MS Office installed [Re: endodave]
endodave Offline
Starting to like KiXtart

Registered: 2005-08-17
Posts: 101
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?

Top
#186535 - 2008-03-28 05:56 PM Re: Determine version of MS Office installed [Re: endodave]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
;*************************************************************************
; 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

Top
#186543 - 2008-03-28 07:30 PM Re: Determine version of MS Office installed [Re: Witto]
endodave Offline
Starting to like KiXtart

Registered: 2005-08-17
Posts: 101
this works beautifully. thanks!
Top
#193743 - 2009-05-08 10:06 PM Re: Determine version of MS Office installed [Re: endodave]
endodave Offline
Starting to like KiXtart

Registered: 2005-08-17
Posts: 101
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


Edited by NTDOC (2009-05-11 11:02 PM)
Edit Reason: Added code tags

Top
#193745 - 2009-05-09 06:43 AM Re: Determine version of MS Office installed [Re: endodave]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
1. Learn to use the code tags. Makes your code much easier to read.
2. Your IF statement is wrong.
IF @WKSTA <> "name"
_________________________
Today is the tomorrow you worried about yesterday.

Top
#193747 - 2009-05-09 03:34 PM Re: Determine version of MS Office installed [Re: Gargoyle]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
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
_________________________
Actually I am a Rocket Scientist! \:D

Top
#193772 - 2009-05-11 10:48 PM Re: Determine version of MS Office installed [Re: endodave]
endodave Offline
Starting to like KiXtart

Registered: 2005-08-17
Posts: 101
hi, i put the workstation name in quotes (IF @WKSTA <> "name"), but it is still being included.
Top
#193777 - 2009-05-12 09:24 AM Re: Determine version of MS Office installed [Re: endodave]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 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.

Top
#193800 - 2009-05-12 06:03 PM Re: Determine version of MS Office installed [Re: Richard H.]
endodave Offline
Starting to like KiXtart

Registered: 2005-08-17
Posts: 101
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


Edited by Benny69 (2009-05-12 07:14 PM)
Edit Reason: Added Code Tags

Top
#193802 - 2009-05-12 07:14 PM Re: Determine version of MS Office installed [Re: endodave]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
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
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#194365 - 2009-06-23 05:43 PM Re: Determine version of MS Office installed [Re: Benny69]
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
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
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#194380 - 2009-06-24 09:35 AM Re: Determine version of MS Office installed [Re: Radimus]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 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

Top
#194394 - 2009-06-24 03:44 PM Re: Determine version of MS Office installed [Re: Richard H.]
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
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
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#194458 - 2009-06-26 12:52 AM Re: Determine version of MS Office installed [Re: Radimus]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
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.
Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 248 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.077 seconds in which 0.026 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org