Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for 4allmembers.bat

(view source code of 4allmembers.bat as plain text)

  1. @ECHO OFF
  2. VER | FIND "Windows NT" >NUL
  3. IF ERRORLEVEL 1 GOTO Syntax
  4.  
  5. :: Parameter check
  6. IF [%2]==[] GOTO Syntax
  7. NET GROUP %1 /DOMAIN >NUL 2>NUL
  8. IF ERRORLEVEL 1 GOTO Syntax
  9.  
  10. :: Main command
  11. FOR /F "skip=8 tokens=*" %%A IN ('NET GROUP %1 /DOMAIN ^| FIND /V "The command"') DO FOR %%? IN (%%A) DO CALL :Command %%? %*
  12. GOTO End
  13.  
  14.  
  15. :Command
  16. SETLOCAL
  17. SET user$=%1
  18. SHIFT
  19. :Loop
  20. SHIFT
  21. IF [%1]==[] GOTO Continue
  22. IF %1==#   SET command$=%command$% %user$%
  23. IF %1=="#" SET command$=%command$% %user$%
  24. IF NOT %1=="#" IF NOT %1==# SET command$=%command$% %1
  25. GOTO Loop
  26. :Continue
  27. IF "%command$%"==" " GOTO Syntax
  28. CALL %command$%
  29. ENDLOCAL
  30. GOTO:EOF
  31.  
  32.  
  33. :Syntax
  34. ECHO.
  35. ECHO 4AllMembers,  Version 1.10 for Windows NT
  36. ECHO Written by Rob van der Woude
  37. ECHO Execute a command once for each member of a global group
  38. ECHO.
  39. ECHO Usage:  4AllMembers  ^<global_group^>  ^<command^>  [ ^<parameters^> ]
  40. ECHO.
  41. ECHO Command will be executed once for each member of global_group
  42. ECHO Command line parameter(s) "#" will be substituted by user ID
  43.  
  44. :End
  45.  

page last uploaded: 2017-08-21, 14:26