|
|
|
| 26 March 2002 | QueryHotFix() |
| Author | ScriptLogic Corporation |
| Action | Queries the installation of a specific Operating System Hot Fix or displays all Hot Fixes installed on the specified computer. |
| Syntax | QueryHotFix (Computer, [HotFix]) |
| Parameters | |
| Remarks | The computer name can be supplied with or without leading backslashes. The Hot Fix name can be supplied with or without the leading "Q". |
| Returns | If a specific Hot Fix is supplied as the second parameter, the return code of this function will be a numeric 1 or 0 (zero), based on whether the Hot Fix is installed or not, respectively. If the second parameter is omitted, this function will return a list of all Hot Fixes installed (each one separated by a single space in a text string). |
| Examples |
; example 1
?'List of all hot fixes installed on this computer:'
$HFarray=split(QueryHotFix(@WKSTA),' ')
for each $element in $HFarray
? $element
next
; example 2
:loop1
?'Test for a specific hot-fix'
?'Enter computer name:'
gets $cname
if not $cname
$cname=@WKSTA
endif
?'Enter HotFix name:'
gets $hfname
$result=QueryHotFix($cname,$hfname)
if $hfname
if $result
? $HFname+' is installed on '+$cname
else
? $HFname+' is NOT installed on '+$cname
endif
else
? 'The following hot fixes are installed on '+$cname+':'
? $result
endif
goto loop1
|
| Source |
FUNCTION QueryHotFix ($computer, OPTIONAL $hotfix)
; Author: ScriptLogic Corporation
; Parameter 1 (required): The computer to query. '' = current computer.
; Parameter 2 (optional): The hotfix name to query about.
; If parameter 2 is omitted, a string of all installed hotfixes is returned.
; Alternatively, Parameter 2 can be the name of a specific hotfix to test for:
; If the hotfix is installed, this function returns a numeric 1.
; If the hotfix is not installed, this function returns a numeric 0.
; This function is only supported on the NT-family of products (NT4/2000/XP/etc.)
DIM $key, $hf, $index
$queryhotfix=''
IF (@inwin = 1)
IF ($computer = '')
$computer=@wksta
ENDIF
IF (Substr($computer,1,2) <> '\\')
$computer='\\'+$computer
ENDIF
$key=$computer+'\HKLM\Software\Microsoft\Windows NT\CurrentVersion\Hotfix'
IF (''+$hotfix = '') ; no parameter supplied. Enum all and return as a string.
$index=0
:hfloop
$hf=EnumKey($key,$index)
IF @error=0
$queryhotfix=$queryhotfix+' '+$hf
$index=$index+1
GOTO hfloop
ENDIF
$queryhotfix=Substr($queryhotfix,2,Len($queryhotfix))
ELSE ; check if a specific hotfix is installed
IF InStr('0123456789',Left($hotfix,1)) ; if it starts with a number, prepend a Q
$hotfix='Q'+$hotfix
ENDIF
$queryhotfix=KeyExist($key+'\'+$hotfix)
ENDIF
ENDIF
ENDFUNCTION ; - QueryHotFix -
|
|
|
|