Here is the script that works based upon group membership:
Group Names based upon - default or additional printer + server + share
DefPrinter_MRH-01_Q-MIS2
AddlPrinter_MRH-01_Q-MIS1
code:
;http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=1;t=007920
call @ScriptDir+'\PriMapState.udf'
call @Scriptdir+'\MapPrinter.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) = "DefPrinter_"
$defprinter = substr($GrpName,12)
$defprinter = join(split($defprinter,"_"),"\")
Mapprinter("\\" + $defprinter,1)
if not PriMapState("\\" + $defprinter)
? "Status - Printer not connected \\"+$defprinter
$S=AddPrinterConnection("\\" + $defprinter)
? "Status - Printer added \\"+ $defprinter
? @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,12) = "AddlPrinter_"
$addlprinter = substr($GrpName,13)
$addlprinter = join(split($addlprinter,"_"),"\")
if not PriMapState("\\" + $addlprinter)
? "Status - Printer not connected \\" + $addlprinter
$S=AddPrinterConnection("\\" + $addlprinter)
? "Status - Printer added \\" + $addlprinter
? @serror
?
endif
endif
next
endif
[ 13. October 2003, 22:10: Message edited by: tjcarst ]