#39102 - 2003-04-16 10:51 AM
Re: Adding Printer Mare
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Easy as a very easy thing indeed.
Final question, are the printers all attached to the same print server?
If so you are in for a real treat.
Here is some sample code which assumes: 1) The print server is static. 2) The group names areformal and consistant. 3) So are the printer names.
Given that your print server is "\\MyPrintServer", your groups are "Printer: HP1", "Printer: Colour_HP2" etc the following (untested) should work:
$sPrintServer="\\MyPrintServer" $iIndex = 0 $sGroup=EnumGroup($iIndex) While $sGroup ; Not interested in domain. If InStr($sGroup,'\') $sGroup=SubStr($sGroup,InStr($sGroup,'\')+1) EndIf If Instr($sGroup,"Printer: ")=1 $sPrinter=SubStr($sGroup,10) If AddPrinterConnection($sPrintServer+"\"+$sPrinter) "ERROR "+@ERROR+": "+@SERROR+@CRLF+"While mapping "+$sPrintServer+"\"+$sPrinter ? Else "Printer "+$sPrintServer+"\"+$sPrinter+" mapped ok." ? EndIf EndIf $iIndex=$iIndex+1 $sGroup=EnumGroup($iIndex) Loop
|
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 2235 anonymous users online.
|
|
|