Here is an example on how to use the group membership for a computer to control Default Printer
; Mapping Printers
; Deleting printers
$result=DelTree("HKEY_CURRENT_USERPrintersconnections")
; Adding Printers
$result=ADDPRINTERCONNECTION ("\Server01Printer1")
$result=ADDPRINTERCONNECTION ("\Server01Printer2")
AT (16,21) "Setting default Printer... "
If ComputerInGroup ("Group1") = 1
$ = SetDefaultPrinter ("\Server01Printer1")
EndIf
If ComputerInGroup ("Group2") = 1
$ = SetDefaultPrinter ("\Server01Printer2")
EndIf
; ***** UDF ComputerInGroup *****
Function ComputerInGroup($group,optional $Domain)
Dim $oGrp
if not $domain $domain=@domain endif
$oGrp = GetObject("WinNT://" + $domain + "/" + $group + ",group" )
if @error exit 1 endif
if $oGrp.IsMember("WinNT://" + $domain + "/" + @wksta + "$$" )
$ComputerInGroup=1
else
$ComputerInGroup=0
endif
endfunction
Links
Leave a Reply