Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why my batch script its creating standard users and not admin?

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading