When trying to add a global group with a name longer than 20 characters using net.exe I get an error saying that the syntax is incorrect, as follows:
C:\>NET.EXE localgroup MyRemoteUsers "really-long-group-name-here" /ADD
The syntax of this command is:
NET LOCALGROUP [groupname [/COMMENT:"text"]] [/DOMAIN]
groupname {/ADD [/COMMENT:"text"] | /DELETE} [/DOMAIN]
groupname name [...] {/ADD | /DELETE} [/DOMAIN]
This problem is documented by Microsoft here. I need this to work inside a standard .cmd batch file. Is there a simple workaround?
You can use powershell in a batch file like this:
One of the tricks above is to use double quotes for entire command while using single quotes within the commands. This allows you to run the statement from
cmd.exeor inside a .bat/.cmd file.