#132917 - 2005-01-25 06:55 PM
Re: Network Print Mapping
|
bestia
Fresh Scripter
Registered: 2004-08-26
Posts: 36
Loc: Guildford, UK
|
Hi Richard, I created the ini file and saved it on the same dir as the script, then run the script few time but no joy.. It just exits immediatly !!! I have included the scripts..well your scripts, in case you wanted to have a look.. Rgds, Bestia
Break ON CLS $sPrinterIni=".\PrinterMap.ini" $iIndex=0 $iDefaultDone=0 $sGroup=EnumGroup($iIndex) While $sGroup AND Not @ERROR ; Drop domain If InStr($sGroup,"\") $sGroup=SubStr($sGroup,InStr($sGroup,"\")+1) EndIf ; Check if there is a printer map for this group For Each $sPrinter in Split(ReadProfileString($sPrinterIni,"LOCATION "+$sGroup,""),Chr(10)) If $sPrinter $asPrinterPair=Split(ReadProfileString($sPrinterIni,"LOCATION "+$sGroup,$sPrinter),"|") "Mapping primary printer path "+$asPrinterPair[0] If AddPrinterConnection($asPrinterPair[0]) " " Color r+/n "*FAILED*" Color w/n @CRLF "Mapping alternative printer path "+$asPrinterPair[1] If AddPrinterConnection($asPrinterPair[1]) " " Color r+/n "*ALSO FAILED*" Color w/n @CRLF "Reason: ["+@ERROR+"] "+@SERROR+@CRLF Else " " Color g+/n "OK" Color w/n @CRLF If Not $iDefaultDone "Setting printer as default" If SetDefaultPrinter($asPrinterPair[1]) " " Color r+/n "*FAILED*" Color w/n @CRLF "ERROR: Could not set printer as default."+@CRLF "Reason: ["+@ERROR+"] "+@SERROR+@CRLF Else " " Color g+/n "OK" Color w/n @CRLF $iDefaultDone=1 EndIf EndIf EndIf Else " " Color g+/n "OK" Color w/n @CRLF "Setting printer as default" If Not $iDefaultDone If SetDefaultPrinter($asPrinterPair[0]) " " Color r+/n "*FAILED*" Color w/n @CRLF "ERROR: Could not set printer as default."+@CRLF "Reason: ["+@ERROR+"] "+@SERROR+@CRLF Else " " Color g+/n "OK" Color w/n @CRLF $iDefaultDone=1 EndIf EndIf EndIf EndIf Next $iIndex=$iIndex+1 $sGroup=EnumGroup($iIndex) Loop
Exit 0
and printermap.ini....
[LOCATION PF3Z1] PRIM1556=\\SRIM6110\PRIM1556|\\SRIM6111\PRIM1556 PRIM0936=\\SRIM6111\PRIM0936|\\SRIM6110\PRIM0936 PRIM1784=\\SRIM6110\PRIM1784|\\SRIM6111\PRIM1784
[LOCATION PF3Z3] PRIM0171=\\SRIM6110\PRIM0171|\\SRIM6111\PRIM0171 PRIM1335=\\SRIM6111\PRIM1335|\\SRIM6110\PRIM1335 PRIM4156=\\SRIM6110\PRIM4156|\\SRIM6111\PRIM4156
[LOCATION PF4Z3] PRIM1551=\\SRIM6122\PRIM1551|\\SRIM6109\PRIM1551 PRIM1550=\\SRIM6109\PRIM1550|\\SRIM6122\PRIM1550 PRIM1782=\\SRIM6122\PRIM1782|\\SRIM6109\PRIM1782 PRIM1347=\\SRIM6109\PRIM1347|\\SRIM6122\PRIM1347
[LOCATION PF4Z4] PRIM1551=\\SRIM6122\PRIM1551|\\SRIM6109\PRIM1551 PRIM1550=\\SRIM6109\PRIM1550|\\SRIM6122\PRIM1550 PRIM1782=\\SRIM6122\PRIM1782|\\SRIM6109\PRIM1782 PRIM1347=\\SRIM6109\PRIM1347|\\SRIM6122\PRIM1347
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 75 anonymous users online.
|
|
|