Jump to content

Creating new user with HFSLIP


Oleg_II

Recommended Posts

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 :whistle: 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:

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

Edited by Oleg_II
Link to comment
Share on other sites


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

Edited by Tomcat76
Link to comment
Share on other sites

Tomcat76 :hello:

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 :(

Link to comment
Share on other sites

This is how I'd do it...

@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)

Edited by Tomcat76
Link to comment
Share on other sites

Tomcat76

Thanx. It should be working :thumbup 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 :whistle:

Edited by Oleg_II
Link to comment
Share on other sites

Hi Oleg_II

Here the solution i use for Windows XP OS deployments:

addacc.cmd

@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

@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:

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.

Edited by Bilou_Gateux
Link to comment
Share on other sites

Bilou_Gateux :hello:

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 :( 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:

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 2 weeks later...

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:

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

Edited by Squeeto
Link to comment
Share on other sites

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::hello::huh::realmad:

These are her choices.

Edited by Squeeto
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...