All pastes #639739 Raw Edit

Dark3Lite

public text v1 · immutable
#639739 ·published 2007-07-30 20:37 UTC
rendered paste body
**********************************************************************
; This script will add the appropriate network
; printer for a User depending upon which lab
; computer the User logs into.
;**********************************************************************

$ACL = "\\gdasgu15\TBACL"
$LRC1 = "\\gdasgu15\TBLRC_1"
$LRC2 = "\\gdasgu15\TBLRC_2"
$E217 = "\\gdasgu15\TBE217_1"
$W200 = "\\gdasgu15\TBW200_1"
$W209 = "\\gdasgu15\TBW209"
$W210 = "\\gdasgu15\TBW210"
$RMLRC1 = "\\kmc06\RMLRC1"
$RMLRC2 = "\\kmc06\RMLRC2"


Select
Case Substr(@Wksta,1,6) = "TBE217"
$ = ADDPRINTERCONNECTION($E217)
$PrinterName = $E217
Case Substr(@Wksta,1,5) = "TBLRC"
$ = ADDPRINTERCONNECTION($LRC1)
$ = ADDPRINTERCONNECTION($LRC2)
$PrinterName = $LRC1
Case Substr(@Wksta,1,6) = "TBW200"
$ = ADDPRINTERCONNECTION($W200)
$PrinterName = $W200
Case Substr(@Wksta,1,6) = "TBW209"
$ = ADDPRINTERCONNECTION($W209)
$PrinterName = $W209
Case Substr(@Wksta,1,6) = "TBW210"
$ = ADDPRINTERCONNECTION($W210)
$PrinterName = $W210
Case Substr(@Wksta,1,6) = "RMLRC1"
$ = ADDPRINTERCONNECTION($RMLRC1)
$PrinterName = $RMLRC1
Case Substr(@Wksta,1,6) = "RMLRC2"
$ = ADDPRINTERCONNECTION($RMLRC2)
$PrinterName = $RMLRC2
EndSelect


$Temp = SUBSTR($PrinterName,3,999)
$PrinterServer = SUBSTR($Temp,1,INSTR($TEMP,"\")-1)
$PrinterShare = SUBSTR($Temp,INSTR($TEMP,"\")+1,999)
$RegKey = ",,"+$PrinterServer+","+$PrinterShare



;**********************************************************************
;  The following instructions look through the list of currently
;   installed printers for the one just added.  When found, it
;   sets the Device registry value which represents the default
;   printer.
;**********************************************************************
$Index = 0
WHILE @ERROR = 0
$ValueName = ENUMKEY( "HKEY_CURRENT_USER\Printers\Connections" , $Index )
If @ERROR = 0
	IF INSTR($Valuename,$RegKey) <> 0
		$PrinterType = SUBSTR($ValueName,INSTR($ValueName," - "),999)
		$DeviceName = "\\"+$PrinterServer+"\"+$PrinterShare+$PrinterType+",winspool,Ne0"+$Index+":"
		WRITEVALUE ("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device",$DeviceName,"REG_SZ")
	ENDIF
ENDIF
$Index = $Index + 1
LOOP