I threw this script together very quickly (obviously) for an ad hoc patching project. However, I'm now pulling my hair out because the RegWebDavDis() function does not work as expected.

On some systems, the $Str variable winds up with a "1.3" for the RegWebDavDis() return, even though I've verified that RegWebDavDis() is actually returning a "0".

On a known system with this value in the registry, the function stubbornly returns a zero. I've tried various tricks with cstr() and such to correctly evaluate/return this value, but nothing seems to work.

Any ideas?

code:
  
; Can use parameter to output to file. I.e.
; Kix32.exe GetInfo.kix $Output=c:\temp\myfile.txt

$D=',' ; Delimiter -- in case we go with tab-delimited

'Running GetInfo.kix version 1.1' ? ?

; Collect all data into one variable
$Tmp=@WKSTA + $D + Strip(@IPADDRESS0,' ') + $D + '@DATE @TIME'
$Tmp=$Tmp + $D + GetSQLVer() + $D + GetOS() + $D + GetRole() + $D + GetCSD()
$Tmp=$Tmp + $D + RegWebDavDis() + $D + GetIEVer() + $D + GetMDACVer()
$Tmp=$Tmp + $D + QueryHotFix()

;'RegWebDavDis() returns: ' + RegWebDavDis() ? ?

; Output is: Workstation Name,First IP,Date Time,Full SQL Ver.,OS,Role,SP Number,
; RegWebDavDis (1 or 0),Full IE Version (4 or above),MDAC Version,Hotfixes

; Output to screen or file as needed.
IF $OutFile = ''
'Data NOT saved to file.' ?
$Tmp ?
ELSE
$Tmp ? ?
'(Appending to $OutFile)' ?
$RC=ReDirectOutput($OutFile)
$Tmp ?
$RC=ReDirectOutput('')
ENDIF

FUNCTION GetCSD()
; Strip all alpha characters and spaces (just return service pack number)
$GetCSD=CStr(Strip(@CSD,'abcdefghijklmnopqrstuvwxyz ',1))
ENDFUNCTION

FUNCTION GetIEVer()
; Get the version of IE installed on the system from the registry
DIM $Key, $Val
$Key='HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer'
$Val='Version'
IF KeyExist($Key)
$GetIEVer=CStr(ReadValue($Key,$Val))
ELSE
$GetIEVer='N/A'
ENDIF
ENDFUNCTION

FUNCTION GetMDACVer()
; Return the MDAC version from the registry
DIM $Key, $Val
$Key='HKLM\Software\Microsoft\DataAccess'
$Val='FullInstallVer'
IF KeyExist($Key)
$GetMDACVer=CStr(ReadValue($Key,$Val))
ELSE
$GetMDACVer='N/A'
ENDIF
ENDFUNCTION

FUNCTION GetSQLVer()
; Return full version (i.e. 8.00.679) if MS SQL installed
DIM $Key, $Val
$Key='HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion'
$Val='CSDVersion'
$GetSQLVer=CStr(ReadValue($Key,$Val))
IF $GetSQLVer='' $GetSQLVer='N/A' ENDIF
ENDFUNCTION

FUNCTION GetOS()
; Return abbreviated OS
SELECT
CASE InStr(@PRODUCTTYPE,'Windows NT')
$GetOS='NT4'
CASE InStr(@PRODUCTTYPE,'Windows 2000')
$GetOS='W2K'
CASE InStr(@PRODUCTTYPE,'2003')
$GetOS='W2K3'
CASE 1
$GetOS='Other'
ENDSELECT
ENDFUNCTION

FUNCTION GetRole()
; Return abbreviated role
DIM $t
$t=@PRODUCTTYPE
SELECT
CASE InStr($t,'Domain Controller')
$GetRole='DC'
CASE InStr($t,'Server')
$GetRole='SVR'
CASE 1
$GetRole='WS'
ENDSELECT
ENDFUNCTION

FUNCTION QueryHotFix(OPTIONAL $HotFix)
; Last revised: 2002-Jul-25
; Developed by ScriptLogic Corp. / www.scriptlogic.com
; Parameter: $HotFix (optional)
; If parameter is omitted, a string of all installed hotfixes is returned.
; Alternatively, Parameter 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.)
; Examples for $HotFix parameter:
; \\computer\hotfix
; \\computer
; hotfix
;
DIM $Key, $HF, $i, $aTmp, $sTmp, $Computer
$QueryHotFix=''
IF @INWIN=1
IF Left($HotFix,2)='\\' ; we've been given a computer's name
$sTmp=substr($Hotfix,3)
$aTmp=split($sTmp+'\','\',2)
$Computer=$aTmp[0]
$HotFix=''+$aTmp[1]
ELSE
$Computer=@WKSTA
ENDIF
$Key='\\'+$Computer+'\HKLM\Software\Microsoft\Windows NT\CurrentVersion\Hotfix'
IF ''+$HotFix='' ; no parameter supplied. Enum all and return as a string.
$i=0
$HF=EnumKey($Key,$i)
WHILE @error=0
IF $HF<>'ServicePackUninstall'
$QueryHotFix=$QueryHotFix+' '+$HF
ENDIF
$i=$i+1
$HF=EnumKey($Key,$i)
LOOP
$QueryHotFix=SubStr($QueryHotFix,2)
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

FUNCTION Strip($String, OPTIONAL $sChars, OPTIONAL $bNotCaseSens)
; remove characters (punctuation characters ",.!?;:" by default) from a string
; $String is the string from which you want TO remove characters.
; $sChars is an optional string containing the characters you want removed.
DIM $i, $c, $RC
$String=''+$String $sChars=''+$sChars
IF $sChars = '' $sChars=',.!?;:' ENDIF
FOR $i = 1 TO Len($String)
$c=SubStr($String,$i,1)
IF $sNotCaseSens $RC=SetOption('CaseSensitivity','Off') ENDIF
IF NOT InStr($sChars,$c) $Strip=$Strip+$c ENDIF
IF $sNotCaseSens $RC=SetOption('CaseSensitivity',$RC) ENDIF
NEXT
ENDFUNCTION ; Strip()

FUNCTION RegWebDavDis()
DIM $Key, $Val
$Key='\HKLM\System\CurrentControlSet\Services\W3SVC\Parameters'
$Val='DisableWebDav'
$RegWebDavDis='' + ReadValue($Key,$Val)
IF $RegWebDavDis='' $RegWebDavDis='0' ENDIF
ENDFUNCTION