(view source code of 4allmembers.cmd as plain text)
/* Execute a command For All group Members *//* Command line parsing */parse arg group commandline
if left( group, 1 ) = '"' then parse arg '"'group'"' commandline
if pos( "?", group ) > 0 then call Syntax
if commandline = "" then call Syntax
/* Initialize RexxUtil */if RxFuncQuery( "SysLoadFuncs" ) <> 0 then do
call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
call SysLoadFuncsend/* Initialize LAN Server RexxUtil */if RxFuncQuery( "LoadLsRxutFuncs" ) <> 0 then do
call RxFuncAdd "LoadLsRxutFuncs", "LSRxUt", "LoadLsRxutFuncs"
call LoadLsRxutFuncsend/* Get the requester type (Server, Peer or Requester) *//* If it is not a peer server, get the domain controller name */ReqType = RequesterType()
if ReqType = "PEER" then do
SrvName = ""
endelse do
SrvName = GetDC()
end/* List all users from the specified group */NETGROUPUSERS = 340
myRc = NetGetInfo( NETGROUPUSERS, "groupInfo", SrvName, group )
if myRc <> "0" then do
say "NetGetInfo NETGROUPUSERS "||myRc
EXIT 1
end/* Execute specified command for each user from specified group */do i=1 to groupInfo.0
fullcommand = commandline /* Substitute user ID for "#" */do until upos = 0
upos = pos( "#", fullcommand )
if upos > 0 then do
fullcommand = substr( fullcommand, 1, upos - 1 )||,
groupInfo.i||,substr( fullcommand, upos + 1 )
end end /* Execute command */address CMD "@CMD /C "||fullcommand
endEXIT 0
/* Get domain controller name */GetDC: procedure
NETGETDCNAME = 510
DomainName = value( "DOMAIN", , "OS2ENVIRONMENT" )
parse value NetMisc( NETGETDCNAME, DomainName, "" ) with myRc dcName
if myRc <> "0" then do
say "NetMisc NETGETDCNAME error: "||myRc
exit 9
endreturn dcName/* Get requester type */RequesterType:NETSERVICE = 170
MyRc = NetEnumerate( NETSERVICE, "serviceInfo", "" )
if MyRc <> 0 then do
say "NetEnumerate NETSERVICE error: "||MyRc
exit 9
endif serviceInfo.0 = 0 then do
req_type = "UNKNOWN"
endelse do
req_type = ""
do i = 1 to serviceInfo.0
if serviceInfo.i = "SERVER" then req_type = "SERVER"
endif req_type = "" then do i = 1 to serviceInfo.0
if serviceInfo.i = "PEER" then req_type = "PEER"
endif req_type = "" then do i = 1 to serviceInfo.0
if serviceInfo.i = "REQUESTER" then req_type = "REQUESTER"
end endreturn req_type/* Help message */Syntax: procedure
saysay "4AllMembers, Version 1.00 for OS/2"
say "Executes a command once for every member of a specified group"
say "Written by Rob van der Woude"
saysay "Usage: 4ALLMEMBERS <group> <command> [ <parameters> ]"
saysay '"#" characters in <parameters> will be substituted'
say "by the user ID when <command> is executed"
saysay "Set the environment variable DOMAIN=<logon_domain>"
say "when using this Rexx script in a LAN Server environment"
EXIT 1
returnpage last modified: 2025-10-11; loaded in 0.0074 seconds