Hello all,

I'm writing a quick'n'dirty script to gather all printers installed on the clients for a project I'm working on. I wrote this script, and everything seems to be working ok, EXCEPT for actually writing the line with the Writeline command. I checked this script for quite a while, and I can't figure out why Writeline isn't working, maybe someone can see it clearer than me?
Thanks for your assistance.
Below is the code that I got.

Break ON
$prKey = "HKEY_CURRENT_USER\Printers\Settings"
$count = 0
$value = EnumValue($prKey,$count)
Do
if open(1,"c:\kix\printers.txt",6) = 0
$lenValue = Len($value)
$lenTilSlash = InStrRev($value,"\")
$unc = Left($value, InStrRev($value,"\"))
$prLen = $lenValue - $lenTilSlash
$printer = Right($value, $prLen)
? "Working on Printer: "$unc$printer

$line = ReadLine(1)
; if the file doesn't have any data in it, then just write a new line
if $ERROR <> -1
; Otherwise, go ahead and search for that printer to see if it's already in the
list
If InStr($line,$printer)
? "already in the list"
Else
Do
$line = ReadLine(1)
Until @ERROR = -1
EndIf
Else
WriteLine(1,$printer)
EndIf

Else "Something wrong with opening file"
EndIf

$count = $count + 1
$ = Close(1)
$value = EnumValue($prKey,$count)
Until @ERROR = 259

_________________________
Network Specialist
Chino Unified School District