Using the following script, this is the screen output from the default printer:
-----------------------------------------
Status - Printer not connected MRH-01\Q-MIS1
Status - Printer added MRH-01\Q-MIS1
The operation completed successfully.
Status - Printer not connected MRH-01\Q-MIS2
Status - Printer added MRH-01\Q-MIS2
The operation completed successfully.
Status - Printer not connected MRH-01\Q-MIS2-COLOR
Status - Printer added MRH-01\Q-MIS2-COLOR
The operation completed successfully.
0 The operation completed successfully.
7278
-----------------------------------------
My pc is a member of three groups and the printers are added if not present, not added if present.
The wrong printer is default, it is not the
primary group.
code:
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
;********** Beginning of printer mapping *********
$WS = GetObject("WinNT://" + @domain + "/" + @wksta + "$$")
if @error
? @serror
else
for each $grp In $WS.Groups
$GrpName = $grp.Name
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
;set default printer
$PrimaryGrpID = $WS.Get("PrimaryGroupID")
? "@error @serror"
? $PrimaryGrpID
if left($PrimaryGrpID,8) = "Printer_"
$defprinter = substr($PrimaryGrpID,9)
$defprinter = join(split($defprinter,"_"),"\")
if PriMapState("\\" + $defprinter)
$S=SetDefaultPrinter ("\\" + $defprinter)
? "Status - Default Printer set"
? @serror
endif
endif
endif
[ 10. October 2003, 05:38: Message edited by: tjcarst ]