Home > front end >  Why my batch script its creating standard users and not admin?
Why my batch script its creating standard users and not admin?

Time:12-05

I'm trying to run the following command to generate a admin user using Batch. But everytime I run it, it just create standard users.

Someone can please give me a hint ?

@echo off

rem Prompt the user for the username of the admin user
set /p username=Enter the username of the admin user:

rem Prompt the user for the password of the admin user
set /p password=Enter the password of the admin user:

rem Create the admin user
net user %username% %password% /add

rem Add the admin user to the local Administrators group
net localgroup Administrators %username% /add

CodePudding user response:

It looks like you are using the correct commands to create a user and add them to the local Administrators group. However, the issue may be with the net user command.

The net user command has a parameter called /add which is used to create a new user account. However, this parameter does not specify that the user is an administrator.

To create an administrator user, you need to use the /add parameter along with the /active:yes and /passwordchg:no parameters. These parameters specify that the user account is active and that the user cannot change their password.

Here is an updated version of the commands that you can use to create an administrator user:

net user %username% %password% /add /active:yes /passwordchg:no
net localgroup Administrators %username% /add

These commands should create the admin user and add them to the local Administrators group. You can verify this by checking the user accounts and group memberships in the Windows Control Panel.

  • Related