#4295 - 2002-07-30 12:45 AM
Re: ADDPRINTERCONNECTION QUESTION
|
Anonymous
Anonymous
Unregistered
|
I came up with this on my own, and im sure someone could make it alot tighter. I am submitting it to give you some ideas. Works only with NT and 2000 clients.
code:
;------------------------ ; MAP PRINTERS ;------------------------
$PRINTERC01 = "\\CROM2\3rd" $PRINTERC02 = "\\CROM2\Canon 330PS 3rd view" $PRINTERC03 = "\\CROM2\Canon 6th PS" $PRINTERC04 = "\\CROM2\6TH" $PRINTERV01 = "\\vicpa01\3rd" $PRINTERV02 = "\\VICPS01\VICCANONIR330VIEW3" $PRINTERV03 = "\\VICPS01\VICCANONIR330VIEW6" $PRINTERV04 = "\\VICPS01\VICCANONIR330YATES3" $PRINTERV05 = "\\VICPS01\VICCANONIR330YATES4" $PRINTERV06 = "\\VICPS01\VICLEXT612BIOMETRY" $PRINTERV07 = "\\VICPS01\VICLEXT612PCLACCT" $PRINTERV08 = "\\VICPS01\VICLEXT612PSACCT"
$PV01 = "0" $PV02 = "0" $PV03 = "0" $PV04 = "0" $PV05 = "0" $PV06 = "0" $PV07 = "0" $PV08 = "0"
$DPV01 = "CANNON IR330 PCL 3RD FLOOR VIEW STREET" $DPV02 = "CANNON IR330 PS 3RD FLOOR VIEW STREET" $DPV03 = "CANNON IR330 PS 6th FLOOR VIEW STREET" $DPV04 = "CANNON IR330 PS 3RD FLOOR YATES STREET" $DPV05 = "CANNON IR330 PS 4TH FLOOR YATES STREET" $DPV06 = "LEXMARK T612 3RD FLOOR VIEW - BIOMETRY" $DPV07 = "LEXMARK T612 4TH FLOOR VIEW - ACCOUNTING" $DPV08 = "LEXMARK T612 4TH FLOOR VIEW - ACCOUNTING"
; IF @INWIN = "2" ; $OS = "9X" ; ENDIF
;------------------------
;------------------------ ;Builds list of installed printers and writes to c:\printers.txt - for each user. ;------------------------
Break ON $Key = "HKEY_CURRENT_USER\Printers\Connections" $prt_log = "C:\Printers.txt"
Del $prt_log
$SubKey = EnumKey( $Key , 0 ) $INDEX = 0 While @ERROR = 0 $wrk = SubStr($Subkey,3,30) $comma = InStr($wrk,",") $svrend = $comma - 1 $prtsrt = $comma + 1 $svr = Rtrim(SubStr($wrk,1,$svrend)) $prt = Rtrim(SubStr($wrk,$prtsrt,20)) $uncname = "\\"+$svr+"\"+$prt $rc = Open(1,$prt_log,5) $rc = WriteLine(1,$uncname+Chr(13)+Chr(10)) $rc = Close(1) $INDEX = $INDEX + 1 $SubKey = EnumKey( $Key ,$INDEX) Loop $Total_printers = $INDEX - 1 ? "Written "+$Total_printers+" entries to "+$prt_log ?
;------------------------
;------------------------ ; Search c:\printners.txt for printer and set on-off value for each printer. ;------------------------
$file = "c:\printers.txt"
If Open(1,$file) = "0" $string = "" + $PRINTERV01 $line = ReadLine(1) While @error = "0" If InStr($line,$string) $PV01 = "1" EndIf $line = ReadLine(1) Loop $q=Close(1) EndIf
If Open(1,$file) = "0" $string = "" + $PRINTERV02 $line = ReadLine(1) While @error = "0" If InStr($line,$string) $PV02 = "1" EndIf $line = ReadLine(1) Loop $q=Close(1) EndIf
If Open(1,$file) = "0" $string = "" + $PRINTERV03 $line = ReadLine(1) While @error = "0" If InStr($line,$string) $PV03 = "1" EndIf $line = ReadLine(1) Loop $q=Close(1) EndIf
If Open(1,$file) = "0" $string = "" + $PRINTERV04 $line = ReadLine(1) While @error = "0" If InStr($line,$string) $PV04 = "1" EndIf $line = ReadLine(1) Loop $q=Close(1) EndIf
If Open(1,$file) = "0" $string = "" + $PRINTERV05 $line = ReadLine(1) While @error = "0" If InStr($line,$string) $PV05 = "1" EndIf $line = ReadLine(1) Loop $q=Close(1) EndIf If Open(1,$file) = "0" $string = "" + $PRINTERV06 $line = ReadLine(1) While @error = "0" If InStr($line,$string) $PV06 = "1" EndIf $line = ReadLine(1) Loop $q=Close(1) EndIf
If Open(1,$file) = "0" $string = "" + $PRINTERV07 $line = ReadLine(1) While @error = "0" If InStr($line,$string) $PV07 = "1" EndIf $line = ReadLine(1) Loop $q=Close(1) EndIf
If Open(1,$file) = "0" $string = "" + $PRINTERV08 $line = ReadLine(1) While @error = "0" If InStr($line,$string) $PV08 = "1" EndIf $line = ReadLine(1) Loop $q=Close(1) EndIf
;------------------------
;------------------------ ; MAP PRINTERS: ;------------------------ ; CHECK FOR PRINTER GROUP MEMBERSHIP ; IF OK, CHECK FOR PRINTER MAP ; IF EXIST, SKIP, IF NOT EXIST, MAP ;------------------------ ; To be used with location groups - to identify location of user. ;------------------------
; MAPS PRINTERS FOR ALL USERS
;For Win98 and NT users, use..
If InGroup("6th Floor View") If $PV03 = "0" If AddPrinterConnection ("" + $PRINTERV03) = "0" ? "ADDED PRINTER: "+ $DPV03 EndIf EndIf
If $PV07 = "0" If AddPrinterConnection ("" + $PRINTERV07) = "0" ? "ADDED PRINTER: "+ $DPV07 EndIf EndIf EndIf
If InGroup("3rd Floor View")
If $PV01 = "0" If AddPrinterConnection ("" +$PRINTERV01) = "0" ? "ADDED PRINTER: "+ $DPV01 EndIf EndIf
If $PV02 = "0" If AddPrinterConnection ("" + $PRINTERv02) = "0" ? "ADDED PRINTER: "+ $DPV02 EndIf EndIf
If PV06 = "0" If AddPrinterConnection ("" + $PRINTERv06) = "0" ? "ADDED PRINTER: "+ $DPV06 EndIf EndIf EndIf
If InGroup("4th Floor Yates")
If $PV05 = "0" If AddPrinterConnection ("" + $PRINTERV05) = "0" ? "ADDED PRINTER: "+ $DPV05 EndIf EndIf EndIf
If InGroup("3rd Floor Yates")
If $PV04 = "0" If AddPrinterConnection ("" + $PRINTERV04) = "0" ? "ADDED PRINTER: "+ $DPV04 EndIf EndIf EndIf
If InGroup("Vic Acct")
If $PV07 = "0" If AddPrinterConnection ("" + $PRINTERV07) = "0" ? "ADDED PRINTER: "+ $DPV07 EndIf EndIf
If $PV08 = "0" If AddPrinterConnection ("" + $PRINTERV08) = "0" ? "ADDED PRINTER: "+ $DPV08 EndIf EndIf EndIf
?
Return end
works for me.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1176 anonymous users online.
|
|
|