Thanks, Howard.
Here is what I was testing, I was just posting my code as I thought your code to get primary was only going to get all groups. Mine didn't work, so I omitted. Not too wise, as you had nothing to review.
The modified code you posted is different, I'll work on that and let you know outcome.
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)
; $Returncode=AddPrinterConnection("\\" + $printer)
? "Status - Printer added "+$printer
? @serror
?
endif
endif
next
;set default printer
; $CompAcct = GetObject("WinNT://DomainName/CompName1$$,user")
$CompAcct = GetObject("WinNT://" + @domain + "/" + @wksta + "$$")
if @error
? @serror
else
$PrimaryGrpID = $compAcct.Get("PrimaryGroupID")
if left($PrimaryGrpID,8) = "Printer_"
$defprinter = substr($PrimaryGrpID,9)
$defprinter = join(split($printer,"_"),"\")
if PriMapState("\\" + $defprinter)
$S=SetDefaultPrinter ("\\" + $defprinter)
? "Status - Default Printer set"
? @serror
endif
endif
endif
endif
[ 11. October 2003, 01:42: Message edited by: tjcarst ]