Hi all,
I am new to creating Bat scripts and I am trying to do something very simple which does not seem to be working.
I am simply trying to create a new local user and add them to the local Administrators group. I am also trying to set the password to never expire.
Below is my code :
net user ADMIN2 ******* /add /active:yes
wmic useraccount WHERE Name='ADMIN2' set PasswordExpires=false
net localgroup Administrators ADMIN2 /add
My code performs the first two lines, but does not add the the user to the local administrators group.
This is probably something very simple.
Thanks for the help in advance
Create Local User and add to local admin group
Moderator: DosItHelp
Re: Create Local User and add to local admin group
I don't know if this is the reason, but keep in mind that the NET command expects to get localized names. E.g. the name of the administrators group would be "Administratoren" for my German settings.
Steffen
Steffen
Re: Create Local User and add to local admin group
Your command for net localgroup "looks" correct. Can you run that from the command line directly? If not, do you receive an error? Does it work if you run the batch script as Administrator?NewDosLearner wrote: ↑13 Oct 2021 04:31net localgroup Administrators ADMIN2 /add
My code performs the first two lines, but does not add the the user to the local administrators group.
This is probably something very simple.
Thanks for the help in advance