Help - Search - Members - Calendar
Full Version: Creating new user with HFSLIP
MSFN Forums > Member Contributed Projects > HFSLIP

   
Google Internet Forums Unattended CD/DVD Guide
Oleg_II
Could somebody with batch scripting skills help to write the code for creating a user with HFSLIP? With choosing a user name and a password of cause whistling.gif It could be possibly included and run from HFSLIP.CMD.

I used 3 methods for creating a user.

1. Including in INSTALL.INF and placing in HFSVPK folder these lines:
CODE
HKLM,"Software\Microsoft\Windows\CurrentVersion\RunOnce\Setup","Add User1",,"%11%\cmd.exe /c net user Oleg z /add"
HKLM,"Software\Microsoft\Windows\CurrentVersion\RunOnce\Setup","Add User1 Group",,"%11%\cmd.exe /c net localgroup Administrators Oleg /add"
HKLM,"Software\Microsoft\Windows NT\CurrentVersion\Winlogon","DefaultUserName",0,"Oleg"
But I couldn't find the way to determing a password in INF file and creat a user name consisting from two or more words like "Oleg 2" newwink.gif

2. Including in APPZ.CMD and placing in HFSVPK folder these lines:
CODE
net user "Oleg 2" z /add
net localgroup Administrators "Oleg 2" /add
net accounts /maxpwage:unlimited
This can be followed by
CODE
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /d %UserName% /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /d 1 /f
Unfortunately something had been changed and the user can't login at the first startup also. And the user name and password are predetermed in this case too.

3. Creating a separate USER.CMD using slightly modified Squeeto's idea:
CODE
@echo off
cls
echo.
echo Creating Windows Account
set /p UserName=Please enter a Name:
set /p Pass=Please enter a Password:
echo.
echo Creating ...
net user "%UserName%" "%Pass%" /add
echo Adding ...
net localgroup Administrators %UserName% /add
net accounts /maxpwage:unlimited
echo.
rem Set to default user and user to autologon:
@echo Windows Registry Editor Version 5.00> %SystemDrive%\Temp\logon.reg
@echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]>> %SystemDrive%\Temp\logon.reg
@echo "DefaultUserName"="%UserName%">> %SystemDrive%\Temp\logon.reg
@echo "DefaultPassword"="%Pass%">> %SystemDrive%\Temp\logon.reg
regedit /s %SystemDrive%\Temp\logon.reg
exit
The idea is good, especially with user name and password choosing. But something is going wrong with my installations - new user is created but he doesn't log during the first startup or is not a default user again.
Tomcat76
QUOTE (Oleg_II @ Dec 11 2005, 06:52 PM) *
How can I define this %UserName%?

It was meant to be used inside Squeeto's batch file (as a replacement for the logon.reg file); %UserName% is defined in there. But he's using Windows 2000 and REG.EXE is not included by default so my version wouldn't work for him unless he added REG.EXE to his source.

The first two lines in the code box of "my code" are already defined in the code box of Squeeto's code. Why not just add the third line to Squeeto's code and ditch mine?

@echo "AutoAdminLogon"="1">> %SystemDrive%\Temp\logon.reg
Oleg_II
Tomcat76 welcome.gif
Thanx for replying. I've already got it (about %UserName%).

But the general question - how to define Name and Password is still actuall. Adding %Password% (see this change in my post) helps during installation but something goes wrong and new user is not in the first logon sad.gif
Tomcat76
This is how I'd do it...

CODE
@echo off
net user "Oleg 2" z /add
net localgroup Administrators "Oleg 2" /add
net accounts /maxpwage:unlimited
echo Windows Registry Editor Version 5.00>%SystemDrive%\Temp\logon.reg
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]>>%SystemDrive%\Temp\logon.reg
echo "AutoAdminLogon"="1">>%SystemDrive%\Temp\logon.reg
echo "DefaultPassword"="">>%SystemDrive%\Temp\logon.reg
echo "DefaultUserName"="Oleg 2">>%SystemDrive%\Temp\logon.reg
echo "ForceAutoLogon"="1">>%SystemDrive%\Temp\logon.reg
regedit -s %SystemDrive%\Temp\logon.reg
exit


(edited; forgot to include AutoAdminLogon)
Oleg_II
Tomcat76
Thanx. It should be working thumbup.gif Will try it next time.

I don't need force Autologon, I wand "Oleg 2" appears as default user during first start and I want to enter my password.

And it could be a nice feature for HFSLIP too whistling.gif
Bilou_Gateux
Hi Oleg_II

Here the solution i use for Windows XP OS deployments:

addacc.cmd
CODE
@echo off

rem Username and Password for administrator.
set AdminUser=user
set AdminPass=password

rem Adding user.
net user %AdminUser% %AdminPass% /add /active:yes /expire:never /passwordchg:no
net localgroup Administrateurs %AdminUser% /add
net accounts /maxpwage:unlimited


activate autologon for this new created user
autologon user domain password

populate RunOnceEX
CODE
@echo off

SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx
SET KEY1="HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"

REG ADD %KEY% /V TITLE /D "Pre-Installation" /f

REG ADD %KEY%\000 /VE /D "Renaming computer" /f"
REG ADD %KEY%\000 /V 1 /D "%temp%\zcnclite.exe /wmi:"""Win32_BIOS,SerialNumber""" /sn:"""HP-""" /q /forcerun /log:%temp%\ZCNC.LOG" /f

rem REG ADD %KEY%\002 /VE /D "Clear App Logs" /f
rem REG ADD %KEY%\002 /V 1 /D "%temp%\clearlogs.exe 127.0.0.1 -app" /f

rem REG ADD %KEY%\003 /VE /D "Clear Sys Logs" /f
rem REG ADD %KEY%\003 /V 1 /D "%temp%\clearlogs.exe 127.0.0.1 -sys" /f

REG ADD %KEY%\004 /VE /D "Changing SID" /f
REG ADD %KEY%\004 /V 1 /D "%temp%\newsid.exe /a" /f

rem REG ADD %KEY%\005 /VE /D "Application Install" /f
rem REG ADD %KEY%\005 /V 1 /D "%temp%\applaunch.exe" /f

REG ADD %KEY%\007 /VE /D "AutoLogonOff" /f
REG ADD %KEY%\007 /V 1 /D "%temp%\nircmd.exe regsetval sz \"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\" AutoAdminLogon 0"

REG ADD %KEY%\008 /VE /D "CYT" /f
REG ADD %KEY%\008 /V 1 /D "%temp%\cyt.exe /user:Bilou_Gateux /y /setprimary" /f

REG ADD %KEY%\009 /VE /D "Network" /f
REG ADD %KEY%\009 /V 1 /D "%temp%\nircmd exec \"%temp%\nbpshpop.exe +S: \\server\share\"" /f

REG ADD %KEY%\010 /VE /D "CleanUp" /f
REG ADD %KEY%\010 /V 1 /D "%temp%\delayexec \"%temp%\cleanup.exe /y /A /P:%temp% /Q\" 60" /f


One utility may be of some interest for you:
QUOTE
Cover Your Tracks v2.30 (Cyt.exe) Last Updated: 11/29/2000

Allows you change the default user name shown at logon the prompt. Useful when you have logged into someone else's machine and you don't want them to lock out your account by typing in their password with your user ID. Requires the latest versions of the Microsoft Visual Basic 5 run-time files (MSKB 180071). Use 'Cyt /?' to view the syntax.
Oleg_II
Bilou_Gateux welcome.gif
Sorry for not replying earlier. I found interesting imformation in your post. Thank you very much!
But unfortunatelly I can't get it working - during the first start Administrator is shown again but not a user I'm trying to define sad.gif And I don't want to use any third party tools for this simple task. I'd better type once during first startup.

And one question:
CODE
net user %AdminUser% %AdminPass% /add /active:yes /expire:never /passwordchg:no
- what means "/active:yes"? Does it intend to make this user default? Something changing all settings back to Administrator.
tommyp
/active:yes enables the account. If you changed it to /active:no, it would create the account but the user would not be able to sign in.

There is another command called cacls which is used to set file/folder permissions. If you are going to set permissions on a folder that had previous permissions set, you need to clear the permissions first and then set them up to your liking.
Squeeto
Hey Oleg_II,
I am a little late on this post.
I modified the process again, a little.
The setup prog asks for a unique computer name anyway so why ask it twice?
At the time user.cmd runs, you have USERDOMAIN set to something like OLEG-12345 so:

CODE
@echo off
cls
set | findstr USERDOMAIN>ztemp
FOR /F "TOKENS=2 DELIMS==-" %%I IN (ztemp) DO (
    SET ZUSER=%%I
    )
DEL /F /Q ztemp
echo Creating Windows Account
net user %ZUSER% "" /add
echo Adding ...
net localgroup Administrators %ZUSER% /add
net accounts /maxpwage:unlimited
echo.
rem Set to default user and user to autologon:
@echo Windows Registry Editor Version 5.00> logon.reg
@echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]>> logon.reg
@echo "DefaultUserName"="%ZUSER%">> logon.reg
@echo "AutoAdminLogon"="1">> logon.reg
regedit /s logon.reg
DEL /F /Q logon.reg
exit


So if you enter 'Oleg' as a unique computer name, your user name is OLEG.
Not perfect but ok for now.
Oleg_II
Squeeto welcome.gif
Very interesting! Thanks!
But are you sure
QUOTE
you have USERDOMAIN set to something like OLEG-12345 so
I never figured that blink.gif
Squeeto
I can't remember how Fred's winnt.sif runs 'cause I have my own and half way through my install it asks me to enter a name. This name
will be unique to my system and sets the initial USERDOMAIN environment variable.
It doesn't (usually) end up as a login unless you install without the winnt.sif!
I run my user.cmd initiated from the winnt.sif [GuiRunOnce] section. It runs after the unique name entry but before USERNAME is set.

Interestingly, at this time the USERDOMAIN variable is set to my SQUEETO-HOME. I chop off the -HOME and use what's left for the logon.

Recap:
Unique name page - I enter Squeeto
setup creates (on the same page) a Domain name of SQUEETO-454545 (a bunch of random numbers)
I change the Domain to SQUEETO-HOME because it looks nicer
user.cmd chops off the end and creates ...



My three year old wants a bunch of happy faces so:
blushing.gif welcome.gif huh.gif realmad.gif
These are her choices.
Google Internet Forums Unattended CD/DVD Guide
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.