Quote:

k, if you don't want the extra non-silenced zeros, use this version:
Code:

function LogErrors()
if @error
$errorString = @wksta + "--> " + @serror + " (" + @error + ")"
$=RedirectOutput($ErrorFile)
$errorString ?
$=RedirectOutput("")
endif
endfunction






Thanks a lot for the code, Joel.
It has removed all the zeros from the log file, BUT i dont know why does it still print zeros on the CONSOLE.


Here's the code. (I have written a script to check a registry key of some computers. either the computer name can be mentioned in the script itself or it can be read from an input file)

Code:
 
CLS
;Debug On
Break On

$NotInstalled = "Not Installed.log"
$Installed = "Installed.log"
$ErrorFile = "Errors.log"
$InputFile = "computerlist.txt"

$RegistryValue = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Exchange\Client\Options'
$RegistryKey = 'DumpsterAlwaysOn'
$RegData = '01'

$FileNames = $Installed, $NotInstalled, $ErrorFile
For Each $Item In $FileNames
If Exist($Item)
Del $Item
EndIf
Next


;THIS IS THE LIST OF COMPUTERS FOR WHICH REGISTRY HAS TO BE CHECKED


$ComputerName1 = 'COMPUTER1'
$ComputerName2 = 'COMPUTER2'
$ComputerName3 = 'COMPUTER3'
$ComputerName4 = 'COMPUTER4'

$CompNames = $ComputerName1, $ComputerName2, $ComputerName3, $ComputerName4
For Each $Item In $CompNames
CheckRegValue($Item)
Next


;THE LIST OF COMPUTERS HAS ALSO BEEN MENTIONED IN A .TXT FILE


/*
If Open(3, $InputFile) = 0
$x = ReadLine(3)
While @ERROR = 0
;? "Line read: [" + $x + "]"
CheckRegValue($x)
$x = ReadLine(3)
Loop
Close (3)
Else
Beep
$msg=messagebox("$InputFile not accessible","Check Registry key",0)
;LogErrors(@ERROR,"Input File not accessible")
EndIf
*/

Function CheckRegValue($Item)

$Value = '\\' + $Item + '\' + $RegistryValue


$VersionType = ReadValue($Value,$RegistryKey)
;$msg=messagebox("$VersionType,"version type",0)

If @ERROR=0
;$msg=messagebox($VersionType,"version type",0)
Else
LogErrors(@ERROR,$Item)
EndIf

If VAL($VersionType) = VAL($RegData)

$Handle1 = FreeFileHandle()
If Open( $Handle1 , $Installed , 5 ) = 0
$z = WriteLine($Handle1,@CRLF + $Item)
Close ($Handle1)
;Else
;? "failed to open file $Installed with Handle1, error code : [" + @ERROR + "]"
EndIf

Else

$Handle2 = FreeFileHandle()
If Open( $Handle2 , $NotInstalled , 5 ) = 0
If $VersionType = ""
$VersionType ='N/A'
EndIf
$z = WriteLine($Handle2,@CRLF + $Item + " --> " + " Registry key is: " + $VersionType)
Close ($Handle2)
;Else
;? "failed to open file $NotInstalled with Handle2, error code : [" + @ERROR + "]"
EndIf
EndIf

EndFunction


Function LogErrors($ErrorValue, optional $MiscInfo1, optional $MiscInfo2)


If @ERROR
$errorString = $MiscInfo1 + "--> " + @serror + " (" + @error + ")"
$=RedirectOutput($ErrorFile)
$errorString ?
$=RedirectOutput("")
EndIf

EndFunction




one more thing, if a computer is NOT connected to the network, it takes around 30 seconds to display the reason. Is there any method of reducing this delay.

ReadValue function does not specify any time for pinging to a computer.
Thank you