Add user and assign to group via command line

Get help with installation and setup problems
Post Reply
asawyer13
Posts: 6
Joined: Thu Sep 12, 2019 11:52 am

Add user and assign to group via command line

Post by asawyer13 » Fri Nov 08, 2019 4:37 pm

I could have sworn I saw this somewhere but now can't find it.

How can I add a new user and also assign to a group via a command line?

I thought it was something like
add user ding password dong
but need to understand exactly what is needed.

Thanks in advance
Alan

IvanGB
Posts: 93
Joined: Sat Feb 06, 2016 2:26 pm

Re: Add user and assign to group via command line

Post by IvanGB » Sat Nov 09, 2019 1:10 pm

Hi Alan.

This is my AddUser.bat:

Code: Select all

net localgroup %3 /add /comment:"%3"
net user %1 %2 /add /Y /fullname:"%1" /comment:"%3" /passwordchg:NO
wmic useraccount where "name='%1'" set passwordexpires=FALSE
net localgroup %3 %1 /add
Then I have another .bat (AddUserList.bat) where I enter the list of users I need to add:

Code: Select all

call AddUser Ding1 Dong1 DingCompany
call AddUser Ding2 Dong2 DingCompany
After that, run AddUserList as Administrator.

Hope it helps.

Ivan

Post Reply