Okay here's the script.
It seems to do what I need. I have to create a group for the default printer and a group for secondary printers, but it works, even if a little cumbersome.
tjcarst
code:
;http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=1;t=007920
call @ScriptDir+'\PriMapState.udf'
;********** Prevent script from running on a server or Win95*********
if @userid = administrator
call @Scriptdir+'\osid.udf'
$os=osid()
if $os[1]='Win95' or $os[2]<>'Workstation'
exit 0
endif
endif
;********** Prevent script from running on Medrec pcs *********
if InGroup ("Medrec Group")
exit 0
endif
;********** Beginning of printer mapping *********
$WS = GetObject("WinNT://" + @domain + "/" + @wksta + "$$")
if @error
? @serror
else
for each $grp In $WS.Groups
$GrpName = $grp.Name
;--- Add and set default printer ---
if left($GrpName,11) = "PrinterDef_"
$defprinter = substr($GrpName,12)
$defprinter = join(split($defprinter,"_"),"\")
if not PriMapState("\\" + $printer)
? "Status - Printer not connected \\"+$printer
$S=AddPrinterConnection("\\" + $printer)
? "Status - Printer added \\"+$printer
? @serror
?
$S=SetDefaultPrinter ("\\" + $defprinter)
? "Status - Default Printer set \\"+$defprinter
? @serror
endif
if PriMapState("\\" + $defprinter)<>2
$S=SetDefaultPrinter ("\\" + $defprinter)
? "Status - Default Printer set \\"+$defprinter
? @serror
endif
endif
;--- Add additional printers ---
if left($GrpName,8) = "Printer_"
$printer = substr($GrpName,9)
$printer = join(split($printer,"_"),"\")
if not PriMapState("\\" + $printer)
? "Status - Printer not connected \\"+$printer
$S=AddPrinterConnection("\\" + $printer)
? "Status - Printer added \\"+$printer
? @serror
?
endif
endif
next
endif