August 10, 200521 yr 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 OFFTitle Create UserCOLOR 0ACLSECHO 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% /addnet localgroup Administrators %user% /addnet accounts /maxpwage:unlimitedThen, 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!
August 10, 200521 yr REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "DefaultUserName" /t REG_SZ /d "%user%" /fREG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "AutoAdminLogon" /t REG_SZ /d "1" /f
August 11, 200521 yr 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 themset 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:: Usersset accntype=:: You need make no changes below here...:AddFullset realname=echo/ Please enter your full name...set /p realname=if '%realname%' equ '' goto AddFullecho/ 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:LogiNameclsset nickname=echo/ Please enter the login name you wish to use...set /p nickname=if '%nickname%' equ '' goto LogiNameecho/ Your login name is %nickname%set /p answr=Is this correct Y/N?set answr=%answr:~0,1%if /i '%answr%' neq 'y' goto LogiNameecho/ 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:UNLIMITEDendlocal&goto :eof Edited August 11, 200521 yr by Yzöwl
August 11, 200521 yr Author Thank you very much jbm! 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!
Create an account or sign in to comment