Jump to content

Adding users


Recommended Posts

Hi, I wanted to add users, however, I wanted the username to be chosen by the installer. And since I didn't know how to do it, I made a batch file.

The file I made look like this:

CLS
@ECHO OFF
Title Create User
COLOR 0A
CLS
ECHO Please type the name of the user, which you want to be created.
start /w wscript.exe "C:\user.vbs"
call "C:\~user.cmd"
del "C:\~user.cmd"
del "C:\user.vbs"
net user %user% /add
net localgroup Administrators %user% /add
net accounts /maxpwage:unlimited

Then, I want to add Autologon, but to be able to use %user% variable, it must be in the batch file (haven't tested it, but I think so).

So is there a kind person who would convert this to REG ADD command?

Windows Registry Editor Version 5.00 

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"DefaultUserName"="%user%"
"AutoAdminLogon"="1"

Thanks!

Link to comment
Share on other sites


REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "DefaultUserName" /t REG_SZ /d "%user%" /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "AutoAdminLogon" /t REG_SZ /d "1" /f

Link to comment
Share on other sites

As jbm has already answered your request, for tutorial purposes, here's an example of how you would ask for the names etc in a batch file

@echo off&setlocal enableextensions

:: If the account needs a password, enter it after the equals symbol below
:: If the account doesn't require a password leave it blank
:: if you use spaces please do not start or end with them

set newpword=

:: Which type of account group would you like for this user
:: Users is the default if left blank
:: If you wish to change it enter your group after the equals symbol below
:: examples
:: Administrators
:: Backup Operators
:: Guests
:: HelpServicesGroup
:: Network Configuration Operators
:: Power Users
:: Remote Desktop Users
:: Replicator
:: Users

set accntype=

:: You need make no changes below here...

:AddFull
set realname=
echo/ Please enter your full name...
set /p realname=
if '%realname%' equ '' goto AddFull
echo/ Your full name is %realname%
set /p answr=Is this correct Y/N?
set answr=%answr:~0,1%
if /i '%answr%' neq 'y' goto AddFull

:LogiName
cls
set nickname=
echo/ Please enter the login name you wish to use...
set /p nickname=
if '%nickname%' equ '' goto LogiName
echo/ Your login name is %nickname%
set /p answr=Is this correct Y/N?
set answr=%answr:~0,1%
if /i '%answr%' neq 'y' goto LogiName
echo/ Thank you %realname%

IF '%newpword%' EQU '' (
NET USER "%nickname%" /ADD /fullname:"%realname%" /passwordreq:no
) else (
echo/ YOUR PASSWORD IS %newpword%
echo/
echo/ IMPORTANT the password is case sensitive
echo/ please make a note of it, you will need
echo/ it in order to gain access to this PC!
pause
NET USER "%nickname%" "%newpword%" /ADD /fullname:"%realname%"
)
IF '%accntype%' equ '' (
NET LOCALGROUP Users "%nickname%" /ADD
) else (
NET LOCALGROUP "%accntype%" "%nickname%" /ADD
)
NET ACCOUNTS /MAXPWAGE:UNLIMITED
endlocal&goto :eof

Edited by Yzöwl
Link to comment
Share on other sites

Thank you very much jbm! :thumbup

Ok, so it is "set /p something=". Thx. However it looks better with the vbs script, I have now completely hidden the cmd file, with "cmdow @ /HID". :)

Thanks again to both of you!

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...