Jump to content

Creating Users Using Net User


Chris.Casey

Recommended Posts

Hi Guys,

I am trying to create a local account using the net user command.

So far, I have added an account by using the command net user username password /add

This only creates the account as a normal user account and I need it to be a member of the administrators group.

Is there anyway you can do this using this command or similar command?

Link to comment
Share on other sites


Heya,

You Could use the line:

net localgroup "Administrators" username /add

Or...

@Echo Off
Cls

::Enter username to be added
Set ChangeUser=Chris.Casey

::Enter group user to be added to
Set DestinationGroup=Administrators

Echo Adding user...
NET LOCALGROUP "%DestinationGroup%" %ChangeUser% /Add
Echo.
Echo Added %ChangeUser% to the %DestinationGroup% group.
Echo.
Pause
Exit

Save as adduser.bat

Hope this helps!!

SilverB.

Edited by SilverBulletUK
Link to comment
Share on other sites

As an after thought, to add a few users, and add them to groups try this...

AddUsers.bat

@Echo Off
FOR /F "skip=14 tokens=1,2,3 delims=:" %%a IN (Users.ini) DO CALL :ProcessINI %%a %%b %%c
GOTO :EOF
:ProcessINI
Set XPCDUser=%~1
Set XPCDPass=%~2
Set XPCDGroup=%~3
IF '%XPCDUser%'=='' GOTO :USRCLEAN
IF '%XPCDPass%'=='' SET XPCDPass=password
IF '%XPCDGroup%'=='' SET XPCDGroup=Users
NET USER %XPCDUser% %XPCDPass% /ADD>>NUL
Echo %XPCDUser% added to local system accounts
NET LOCALGROUP "%XPCDGroup%" %XPCDUser% /ADD>>NUL
Echo Added %XPCDUser% to %XPCDGroup% group
:USRCLEAN
Set XPCDUser=
Set XPCDPass=
Set XPCDGroup=
:EOF

Users.ini

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::Please all user accounts to be added to the local machine
::::under the [StartUserAccounts] label, in the following format;
::::
::::Example1= Jamie:Jamiespassword:Administrators
::::Example2= Helen:secret:Users
::::
::::Context: Username:Password:Group
::::
::::Please ensure to use ':' and not ';' in user lines.
::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

[StartUserAccounts]

Just add all the users you need in the Users.ini file, each on a new line.

Edited by SilverBulletUK
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...