; Individual printer mapping -------------------------------------------------------------------------------------
For Each $row In $IPrinters
for each $element in $row
if @USERID = $element
; "Map " + $row[0] + " FOR " + @USERID ?
$MyPrinter=$row[0]
addprinterconnection ($MyPrinter)
If AddPrinterConnection ($MyPrinter) = 0
; "Added printer connection to $MyPrinter...." ?
If RedirectOutput($LogFile) = 0 ;log success to log file
"@DATE,@TIME,@MSECS,@USERID,Mapped printer $MyPrinter" ?
EndIf
RedirectOutput("") ;Redirect output back to screen
Else
$errorcode=@Error ;store error code
$errordes=@SERROR ;store error description
; "Printer connection to $MyPrinter failed!" ?;show failed
; "Error code: " + @ERROR + " : " + @SERROR ?;show error code and description
If RedirectOutput($LogFile) = 0 ;log failure to log file
"@DATE,@TIME,@MSECS,@USERID,Printer connection to $MyPrinter failed!" ?
"@DATE,@TIME,@MSECS,@USERID,Errorcode: $errorcode : $errordes" ?
EndIf
RedirectOutput("") ; Redirect output back to screen
EndIf
endif
Next
Next