1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

net.exe help with query..

Discussion in 'Windows Vista' started by ibm37, Oct 12, 2008.

Thread Status:
Not open for further replies.
  1. ibm37

    ibm37 Thread Starter

    Feb 28, 2003
    I Need help to create a batch file to add users, groups, group memberships & passwords..? (for IT course)

    So far I have managed..

    Net User /add Bill.Smith [email protected] (save as bat)


    Users - Bill.Smith | Fred Bloggs | John.Blackmore
    Passwords - [email protected]
    Groups = Sales | Admin | Quality Control

  2. TheOutcaste


    Aug 7, 2007
    Try net help user instead of net user /?
    You'll get a lot more info.
    Net User and Net Group will do what you want.

    You can put the users and their groups into a text file and use a For loop to read the data and then run the net commands as needed

    If your data file is formatted like this:
    Bill.Smith, [email protected],Sales
    Fred Bloggs,[email protected],Sales
    John.Blackmore,[email protected],Quality Control

    Read the file with this:
    FOR /F "tokens=1-3 delims=," %%I In (data.txt) Do (
    commands here
    %%I will be the user name, %%J will be the password, and %%K will be the group name. As you have both user names and group names with spaces, don't forget to put quotes around the variables.
    You can add other info as needed like FULLNAME, USERCOMMENT, etc. Just change the tokens= line to match the number of variables. If you need to use a comma in a comment, you'll need use something else to delimit the file. A tab can be used, but you can't copy and paste a tab (it gets converted to spaces) so be aware of that. Entering the data in a spreadsheet and then saving the file as a tab delimited text file works quite handy though.

    Would be a good idea to first test if the group exists. If it doesn't you'd need to add it first. (Think pipe existing group list to Find with %%K as the search string)


As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Similar Threads - help query
  1. proprboy
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/758523

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice