Scenario

According to a group membership of the current Windows workstation user, you want to run certain commands in a Windows Batch file (cmd, .bat).

 

Solutions

1)

Use file isMember.exe from here. The link also includes a usage example.

 

2)

If you do not trust foreign .exe files, create a file isMember.bat e.g. with this content (original script):

Then run isMember.bat, your group name should be the parameter. You can then use the return code of this script in another one (variable ERROR_LEVEL). Make sure you run it with “call isMember.bat” command, without “call” your main script would also be exited.

Please note the “net user” command used above might cut long group names, so solution 1 could be a better way.

3)

Other ways, but also have to be parsed:

 

 

 

Share This:

  [email protected]