MSFN Forum: Adding users - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Adding users Convert autologon.reg to a batch file Rate Topic: -----

#1 User is offline   Mr_Mo 

  • Newbie
  • Group: Members
  • Posts: 16
  • Joined: 13-April 04

Posted 10 August 2005 - 02:31 PM

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!


#2 User is offline   jbm 

  • Senior Member
  • PipPipPipPip
  • Group: Members
  • Posts: 626
  • Joined: 16-September 04
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 10 August 2005 - 05:16 PM

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


#3 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,195
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 10 August 2005 - 06:39 PM

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 

This post has been edited by Yzöwl: 10 August 2005 - 06:46 PM


#4 User is offline   Mr_Mo 

  • Newbie
  • Group: Members
  • Posts: 16
  • Joined: 13-April 04

Posted 10 August 2005 - 11:29 PM

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!

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy