Hi, how would I list ALL installed printers on a remote print server? I've tried the PrinterList() UDF but it will only display locally installed printers. This is what I've tried:
Code:
$array=printerlist() for each $printer in $array ? $printer next
Did you try reading the liner notes? ;Syntax: ; Printerlist(optional $remotepc,optional $displaymode) ; ;Parameters: ; $RemotePC: (Optional) ; Remote Computer. If omitted defaults to localpc.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.
Quote: Hi, how would I list ALL installed printers on a remote print server? I've tried the PrinterList() UDF but it will only display locally installed printers. This is what I've tried:
Thanks for any suggestions!
Hoopes
Well because you're not using it correctly.
Code:
$array='system1,system2,system3' for each $printer in $array printerlist($printer) next
DOC, You too, need to learn to read. ;Action: ; Creates an array/list of Printers, and optionally their ports installed, on a local or remote computer.
;Returns: ; Array of Printers
Edited by Les (2006-04-0612:40 AM)
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.
I only have one print server so I'm assuming this is the way it's supposed to look:
Code:
Dim $PrinterArray, $Printer $PrinterArray=PrinterList('printserver') ; is it supposed to be \\printsever or printserver? I've tried both and neither work. For Each $Printer In $PrinterArray 'Computer: ' + $Printer ? Next
The problem is that it still isn't displaying any printers. Any ideas?
Break On For Each $Printer in Printerlist('FFPrint') $Printer ? Next Function PrinterList(optional $remotepc, optional $displaymode) dim $service,$printer,$printers,$printerdesc[0],$counter,$portname,$printername if $remotepc="" $remotepc="." endif $Service = GetObject("winmgmts:\\" + $remotepc + "\root\cimv2") if @error exit @error endif $Printers=$service.execquery ('select * from Win32_Printer') for each $printer in $printers redim preserve $printerdesc[$counter] if $displaymode & 1 $portname = "," + $printer.portname endif select case $displaymode & 4 ;remote printers if left($printer.portname,2)="\\" $printername=$printer.name endif case $displaymode & 2 ;local printers if left($printer.portname,2)<>"\\" $printername=$printer.name endif case 1 ; all printers $printername=$printer.name endselect if $printername<>"" $printerdesc[$counter]=$printername + $portname $counter=$counter + 1 $printername="" endif next $PrinterList=$printerdesc endfunction
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.
Still a no go. Does it have something to do with W2K3?
Code:
break on dim $SO $SO=setoption('explicit','on') $SO=setoption('novarsinstrings','on') $SO=setoption('nomacrosinstrings','on')
dim $COMPUTERlIST, $PRINTERARRAY, $COMP, $PRINTER $COMPUTERLIST = split('forest',',') for each $COMP in $COMPUTERLIST if $COMP $PRINTERARRAY=printerlist($COMP) for each $PRINTER in $PRINTERARRAY 'Computer: ' + $COMP + ' ' + $PRINTER ? next endIf next
Are you running the KiX code as administrator? What is the purpose of doing this? I hope you don't plan to enum the printers in a regular logon script.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.
If this is an admin script used to build an INI file for the users to draw from, you could also use remote registry reads from HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\Shares. You would still need to separate the file shares from the printer shares but that would be simple enough.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.