Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to create a script that will enable our automated tool to add certain groups into the localgroups of our servers:

net localgroup dbusers A&B /add

The problem I have is that it doesn't seem to like the "&" symbol.

C:\>net localgroup dbusers 'A&B' /add
The syntax of this command is:

NET LOCALGROUP [groupname [/COMMENT:"text"]] [/DOMAIN]
          groupname {/ADD [/COMMENT:"text"] | /DELETE}  [/DOMAIN]
          groupname name [...] {/ADD | /DELETE} [/DOMAIN]

'B' is not recognized as an internal or external command,
operable program or batch file.

I tried single and double quotes and caret without any success. Can anyone suggest a way to get around this please?


share|improve this question

I know it sounds crazy, but it's actually because of the length of the group name, not because it has a space. That's why the other people responded saying it worked for them (because the group names they tried weren't as long). I was having the same problem you were, but I found out it was because of the long group name that the "net" command wasn't handling properly. Then I found a utility called "lg" from It worked like a champ. Hopefully this info will help someone else who stumbles on this issue.

share|improve this answer

In the Windows Command Prompt, use ^ to escape characters:

net localgroup dbusers "aceina\A^&H Support (Accenture)" /add
share|improve this answer
If I try that i get the following "The syntax of this command is:.." If I single quote I get "System error 1788 has occurred. The trust relationship between the primary domain and the trusted domain failed". – Jon Jun 8 '09 at 12:57

I just did the following using CMD.EXE from a Windows XP Professional SP2-based machine that is a member of the "DOMAIN" W2K3 Active Directory domain, logged-on with a user account that has both local "Administrator" and "Domain Admin" rights:

C:\Documents and Settings\EAnderson>net group "A&B Test" /domain /add
The request will be processed at a domain controller for domain ad.tippcity.k12.

The command completed successfully.

C:\Documents and Settings\EAnderson>net localgroup "users" "DOMAIN\A&B Tes
t" /add
The request will be processed at a domain controller for domain ad.tippcity.k12.

The command completed successfully.

Double quotes look fine to me.

share|improve this answer
C:>net localgroup "administrators" "adom\group012345678901234" /add

The command completed sucessfully

C:>net localgroup "administrators" "adom\group0123456789012345" /add

The syntax of this command is:

[groupname [/COMMENT:"text"]] [/DOMAIN]
              groupname {/ADD [/COMMENT:"text"] | /DELETE}  [/DOMAIN]
              groupname name [...] {/ADD | /DELETE} [/DOMAIN]


Seems net.exe has a problem with long group names. HATE!

share|improve this answer
Wonderful. I just discovered this feature. Looks like net.exe doesn't like usernames that are greater than 25 characters. – splattered bits Dec 22 '10 at 22:00

I know this is a really old thread but since I had this issue and this was one of the first threads to come up in a Google search, I thought I would add what worked for me:

My goal was to use net localgroup to add domain admins to the local administrators group.

I thought the solutions was to use quotes around the "domain\domain admins" part.


c:\> net localgroup administrators "domain\domain admins" /add

This failed with the following message:

There is no such global user or group: “domain\domain.

There is no such global user or group: admins”.

More help is available by typing NET HELPMSG 3783.

The real solution was to put the Quotes around the space:


c:\> net localgroup administrators domain\domain" "admins /add

This worked for me: Solved.

share|improve this answer
net localgroup "A&H Support (Accenture)" /add
The command completed successfully.

Worked a charm.

share|improve this answer

You’ll notice that if you use a “net localgroup administrators /add DOMAIN\Group” that the command fails with a syntax error. Some folks say that this is because of a limitation on the length of the group name, but I call shenanigans on that explanation. At any rate, you’ll slam your head against your desk for a while, until you do the following:

1) Open up Notepad

2) Paste in the following lines, substituting [DOMAINNAME] and [DOMAINGROUPNAME] as necessary:

Set objLocalGroup = GetObject("WinNT://./Administrators")



Set objLocalGroup = Nothing

Set objADGroup = Nothing

3) Go to File > Save As, and save it on your Desktop as “script.vbs”

4) Go to Start and type in cmd, then right-click on cmd and choose “Run as Administrator”:

5) CD to your Desktop and then run the command: “cscript script.vbs” as in the example below, and once the script runs, do a “net localgroup administrators” to verify that the script added the requested group properly:

share|improve this answer

Just use caret symbol, the below works indeed:

C:\>net localgroup dbusers 'A^&B' /add

Notice this is specific to the command above, any program launched from cmd can escape characters as he prefers.

share|improve this answer

protected by Chris S Nov 22 '13 at 16:06

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.