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
Add user and assign to group via command line
Re: Add user and assign to group via command line
Hi Alan.
This is my AddUser.bat:
Then I have another .bat (AddUserList.bat) where I enter the list of users I need to add:
After that, run AddUserList as Administrator.
Hope it helps.
Ivan
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
Code: Select all
call AddUser Ding1 Dong1 DingCompany
call AddUser Ding2 Dong2 DingCompany
Hope it helps.
Ivan