;set index to 0 for looping through groups
$LoopIndex = 0
;get first group name
$UsersGroups = ENUMGROUP($Index)
;loop
DO
;if group name is longer than nothing
if Len($UsersGroups) > 0
;if group name starts with print
if lcase(substr($UsersGroups, 1, 14)) = "westcare\print"
;if group is a printd group, add first
if lcase(substr($UsersGroups, 1, 16)) = "westcare\printd-"
;add printer and make sure it’s successful
if addprinterconnection('\\wcps1\' + lcase(substr($UsersGroups, 17))) = 0
;display success message
? "Added printer: " + substr($UsersGroups, 17)
else
;display error message and text
? "Error Adding Printer: " + substr($UsersGroups, 17)
? "Error: " + @SERROR
endif
;set default printer to group name after add
if setdefaultprinter('\\wcps1\' + substr($UsersGroups, 17)) = 0
;display success message.
? "Set default printer to: " + substr($UsersGroups, 17)
Else
;display error message and text
? "Error Setting Default Printer: " + substr($UsersGroups, 17)
? "Error: " + @SERROR
EndIf
else
;add printer if just a print- group
if addprinterconnection('\\wcps1\' + lcase(substr($UsersGroups, 16))) = 0
;display success message
? "Added printer: " + substr($UsersGroups, 16)
else
;display error message and text
? "Error Adding Printer: " + substr($UsersGroups, 16)
? "Error: " + @SERROR
endif
endif
EndIf
EndIf
;increase the loop counter by 1
$LoopIndex = $LoopIndex + 1
;get next group name
$UsersGroups = ENUMGROUP($LoopIndex)
;loop until end of groups list
UNTIL Len($UsersGroups) = 0