#159863 - 2006-03-27 08:20 PM
Check registry for installed application
|
cuzfu
Lurker
Registered: 2005-08-14
Posts: 2
|
Im a trying to create a script that checks to see it a particular version of software is installed. If it is not up to date then it installs the program.
I am having some trouble listing the registry key's in the uninstall hive. here is my code
$Version = "10.19"
Dim $UninstallKey, $AppKey, $KeyIndex, $Key, $Keys, $KeyExist $KeyExist = 0 $UninstallKey = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' $KeyIndex=0
While @ERROR = 0 $AppKey = EnumKey($UninstallKey, $KeyIndex) $KeyIndex = $KeyIndex + 1 $Keys = $Keys + $UninstallKey + '\' + $AppKey $rc = RedirectOutput("test.log",overwrite) If @ERROR = 0 "Name found: $AppKey"? Endif While $KeyExist = 0 $ValueName = ENUMVALUE ($Keys, $Index) $KeyExist = KeyExist("$AppKey + $ValueName") $Index = $Index + 1
If $KeyExist = 0 "$AppKey: $ValueName"? EndIf Loop Loop
|
|
Top
|
|
|
|
#159866 - 2006-03-27 11:03 PM
Re: Check registry for installed application
|
Mart
KiX Supporter
   
Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
|
Cuzfu,
Your script runs in loop that never stops and only finds the first key. I put together a script that might be helpful in your case. Be aware that I did not test the script and it needs to be changed to the proper keys it should check. I used the Office 2003 key just as an example.
Something like this might work for you.
Code:
;Break on gives the ability to end the script and not get logged off. Break on ; ;Set the required version. $Version = "10.19" ; ;Open the logfile, if it does not exist create it. $rc = Open (1, "c:\log.txt", 5) ; ;This is the key for MS Office 2003 Pro. $key = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" $app = "{90110409-6000-11D3-8CFE-0150048383C9}" ; ;Check if the app is installed. $keyexists = KeyExist($key + $app) If $keyexists <> "0" ;Find the displayname and the display version. $dispname = ReadValue($key + $app, "Displayname") $dispversion = ReadValue($key + $app, "Displayversion") ;Write name and version to the logfile. WriteLine(1, "Application: " + $dispname + " version: " + $dispversion + " is installed." + @CRLF) $version is SubStr($version, 1, 5) If $version <> "10.19" WriteLine(1, "Application: " + $dispname + " update required." + @CRLF) ;Start upadte Run "pathtoupdatefile\update.exe" Else WriteLine(1, "Application: " + $dispname + " update NOT required." + @CRLF) EndIf Else WriteLine(1, "Application: " + $app + " is NOT installed." + @CRLF) EndIf ; ;Close the logfile. $rc = Close(1)
Edited by Mart (2006-03-28 09:13 AM)
_________________________
Mart
- Chuck Norris once sold ebay to ebay on ebay.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1376 anonymous users online.
|
|
|