;********** Beginning of printer mapping *********
call @ScriptDir+'\PriMapState.udf'
$WS = GetObject('WinNT://' + @domain + '/' + @wksta + '$$')
if @error
? @serror
else
$ps1='prn01'
$ps2='prn02'
$ps3='prn03'
$ps4='prn04'
$ps5='prn05'
for each $grp In $WS.Groups
$GrpName = $grp.Name
;--- Add additional printers ---
if left($GrpName,2) = 'A0' ;
$psn = substr($Grpname,2,2) ;print server number determined by 2-3 characters A01=PS1
if $psn='01' $ps=$ps1 endif
if $psn='02' $ps=$ps2 endif
if $psn='03' $ps=$ps3 endif
if $psn='04' $ps=$ps4 endif
if $psn='05' $ps=$ps5 endif
$addlprinter = substr($GrpName,5) ;printer group name starts at 5th character Ex. Group D01_q-mis or A01_q-mis
$addlprinter = $ps+'\'+$addlprinter
$addlprinter = '\\'+$addlprinter
? "Additional Printer: "$addlprinter
if not PriMapState($addlprinter)
? "Status: Printer not connected " + $addlprinter
$nul=AddPrinterConnection($addlprinter)
? "Status: Printer added " + $addlprinter
? @serror
endif
endif
;--- Add and set default printer ---
if left($GrpName,2) = 'D0' ;print server number determined by third character D01=PS1 D02=PS2
$defprinter = substr($GrpName,5) ;printer group name starts at 5th character
$psn = substr($Grpname,2,2)
if $psn='01' $ps=$ps1 endif
if $psn='02' $ps=$ps2 endif
if $psn='03' $ps=$ps3 endif
if $psn='04' $ps=$ps4 endif
if $psn='05' $ps=$ps5 endif
$defprinter = $ps+'\'+$defprinter
$defprinter = '\\'+$defprinter
? "** Printers assigned through Printer Setup Group **"
? " "
? "Default Printer: "$defprinter
if not PriMapState($defprinter)
? "Status: Printer not connected "+$defprinter
$nul=AddPrinterConnection($defprinter)
? "Status: Printer added "+ $defprinter
? @serror
$nul=SetDefaultPrinter($defprinter)
? "Status: Default Printer set "+ $defprinter
? @serror
endif
if PriMapState($defprinter)<>2
$nul=SetDefaultPrinter($defprinter)
? "Status: Default Printer changed "+ $defprinter
? @serror
endif
endif
next
endif