Jump to content

Different User Accounts In An Unattended Install


Recommended Posts

Ok, this might get a bit long-winded, I have been racking my brains for a while....

I have my unattended CD working just fine, I have it totally automated except choosing the partition to install, which I want to do manually anyway.

I have RunOnceEx copy files from a network and run one of the files it copies which then runs a load of scripts to do the updates/applications/reg tweaks.

I know it is probably not the best or most efficient way of doing it, but that way I don't have to change my cd every time I want to alter one of the applications/add a hotfix etc.

OK, that bit was so that you know how I have it set up, now the problem.....

I have cmdlines run a script which creates a user account, and until now I have been having the first part of my script launch the UserAccounts app from the control panel and wait so I can change the account name, but this means it is not unattended, and the account still has the folders in 'Documents and Settings\Owner' (Owner being the account created by my accounts batch run by cmdlines).

What I am looking for is a way to change the user account AND the path to the files. I am thinking of having the batch that runs at the cmdlines.txt point look for a file on a floppy or network source which will have the correct details in it, but using a floppy means changing the boot order or putting the disk in/out, and i don't think I'd be able to access the network at that point...

so, any suggestions? ...or is there an easier way to do this that I am just not looking at!

Link to comment
Share on other sites


I guess Im confused... how does what you want to do differ from this?

That's exactly what I'm using at the moment, but I am installing a number of computers with different users. at the moment I am using the scripts you pointed out tho create an account called 'Owner', then changing the account name to the correct name using the control panel after install.

the problem is that after I have change the username to 'Freddy' (for example) the documents & settings for Freddy are in "C:\Documents and Settings\Owner\" as opposed to "C:\Documents and Settings\Freddy\"

I am looking to either set the username before the install starts (where cmdlines will run the batch to create the account from a floppy or network source, then I will modify the batch for each install) or change the user account after install AND change the path.

The intention is that I can create a file (batch or text) on either a floppy or network source which has the end user's desired account name in it, and either during setup or afterwards, an account with that name is created, with the correct path in the Documents & Settings directory.

Link to comment
Share on other sites

As far as changing the username after its been set, I probably wouldnt recommend that as there are a few references windows uses for it that may not be covered.

What you could do is make a simple batch file that runs during your RunOnceEx stage that you can pass a username with...

EDIT:

So I got bored and decided to make the batch file for ya.... this should be just what you need, if I understand what youre looking to do here. This will prompt to create a user account and ask if you want to add it to the admins group. You can obviously modify it if you want youre users to be added to a different group..

Hope it helps!

@echo off

:START
cls
echo.
echo Create Windows Account
echo ======================
echo Enter a Windows Logon Name and Password you would like to create...
echo.
set /p UserName=Name:
set /p Password=Password:
echo.


:ASKADMIN
set /p CreateAdmin=Add User to Administrators Group? (Type Y or N):
if /I %CreateAdmin%==N goto CREATEUSER
if /I %CreateAdmin%==Y goto CREATEUSER
cls
echo.
echo Invalid Choice.  Please type 'Y' for Yes or 'N' for No. (Without quotes)
echo.
goto ASKADMIN

:CREATEUSER
REM Create User
cls
echo.
echo Creating User Account "%UserName%" with Password of "%password%"...
net user %UserName% %password% /add
echo.
echo.

if /I %CreateAdmin%==Y goto ADDADMIN
REM echo Done.
goto ADDANOTHER


:ADDADMIN
REM Add User to Admin Group
echo.
echo Adding User "%UserName%" to Administrators Group...
net localgroup Administrators %UserName% /add
echo.
REM echo.
REM echo Done.
goto ADDANOTHER


:ADDANOTHER
goto EXIT
REM This section will be skipped so that the only user you setup will also autologon.
REM Ill try to update this later so you can still add multiple users AND have a user autologon.
set /p CreateAnother=Create another User? (Type Y or N):
if /I %CreateAnother%==N goto EXIT
if /I %CreateAnother%==Y goto START
cls.
echo Invalid Choice.  Please type 'Y' for Yes or 'N' for No. (Without quotes)
echo.
GOTO ADDANOTHER


:EXIT
REM Set user to autologon
echo.
Setting User "%UserName%" to Autologon.
REG ADD HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon /v DefaultUserName /t REG_SZ /d %UserName%
REG ADD HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon /v DefaultPassword /t REG_SZ /d %Password%
REG ADD HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon /v AutoAdminLogon /t REG_SZ /d 1
echo.
echo.
echo Done.
pause
exit

Link to comment
Share on other sites

@ Durex

Thanks for posting that code

I would like to have the users created as restricted users.

Would sinply changing

Add User to Administrators Group?

to

Add User to Restricted User Group?

do the trick?

or is there a different term in the setup for a restricted user?

Also how would I set windows to auto logon with the newly created restricted user?

Thank you very much

Link to comment
Share on other sites

I would like to have the users created as restricted users.

Just answer 'No' to the 'Add to Admin Users' question

Also how would I set windows to auto logon with the newly created restricted user?

Ive updated the above code.. the only downside to this would be you cant add multiple users.... well.. you could.. but I really didnt feel like updating the code to allow you to do so. So with the updated code, I REM'd out the entire section on creating another user. Maybe when I have some more time Ill update it so that you can set the 1st user you add to autologon or something.

One last thing to note, in case its not obvious.. just like the normal method of creating a user and having it autologon... you need to make sure this batch file it run during the Command.txt phase of your install and not the RunOnceEx.

Let me know if you have any further questions!

Link to comment
Share on other sites

Durex,

Thanks for putting in the effort to do that batch, it looks like it should be useful to hammermtl, but it is not quite what I am after. the problem is that doing it this waymeans Windows will have to have logged into an account in the first palce for this batch to work, therefore an account (and the files for that account) is created.

I suppose I could run this batch, let it reboot into the new account then use "net user {original username} /delete", but it seems a long way to go about it, and more importantly it is not unattended.

My hope is a way to set the username before I start the install, then the cmdlines (which currently runs my useraccounts.cmd) would run a useraccounts.cmd file specifically created for that user. this method would be unattended, and provide the desired result without adding extra users after the install has completed.

I had a thought over the weekend about making my CD on a RW disk, leaving it open and simply re-writing the useraccounts.cmd file before each install, but it would be a pain, plus I'm not convinced it would work.

Link to comment
Share on other sites

Just off the top of my head....

Somewhere else in the forum I saw a method for a presetup. You could launch a batch file to get the user info and modify a variable or even the oobeinfo.ini.

Another method I have used in the past is a floppy with a batch or text file with the specific user info. This could be launched from cmdlines.

Both would allow for unattended with only minor input at the very beginning or modifying the file on the floppy.

Hope this helps...

Link to comment
Share on other sites

the problem is that doing it this way means Windows will have to have logged into an account in the first palce for this batch to work, therefore an account (and the files for that account) is created.

My hope is a way to set the username before I start the install, then the cmdlines (which currently runs my useraccounts.cmd) would run a useraccounts.cmd file specifically created for that user. this method would be unattended, and provide the desired result without adding extra users after the install has completed.

You didnt read closely enough... like i mentioned previously.. you run this at the cmdlines stage... in other words.. replace your useraccounts.cmd batch file with this code.. so this will launch from you cmdlines.. you enter your account info and upon reboot it will automatically log on with this account and fire off your RunOnceEx.

One thing I should mention is that I havent fully tested this yet.. I tested the batch syntax by replacing the actual commands with 'echo' statements and it worked without issue. For all intensive purposes, this script does exactly what the useraccounts.cmd and autologon.reg files do (outlined in the msfn guide), but simply gives you the option of using a username / password of your choice.

Again... unless Im not understanding you correctly... and that the syntax is correct.. Im pretty sure this is exactly what youre looking for.

As soon as I get a chance Ill test this with a VMWare install to make sure it runs without issue (or better yet, if someone else has a chance give it a shot and post up your results! :thumbup )

Link to comment
Share on other sites

.. you run this at the cmdlines stage...

Durex,

I had a batch like this before, but the failing is that the install is not then unattended, you have to sit and wait for this batch to run. in the enviroment I am in the machine being worked on could be sat there for some time before someone gets to it, and time is money (apparently!).

I have an interim solution which i have tested and is working at the moment, but it is messy:

My CD creates the 'Owner' Account, and copies a set of batch [from my server] files at RunOnceEx...

The first Batch File Creates a new account (sets it to forced logon) and reboots the computer....

the 2nd batch file deletes the Owner Account and removes the Force Logon, then deletes the 'Owner' directory from Documents & Settings.

Messy, but it is working for the moment. All I have to do is edit the first Batch File on my server to use the correct Account Name (and the Registered Owner details) when I start the Install.

This is pretty much what I was after, unattended once the file has been created and the install started, it's just a shame it has to create the Owner account then delete it afther the first boot.

Link to comment
Share on other sites

Hmm.. I guess I did misunderstand you.. and to be honest, Im still not completely sure why you want to create an account, then delete it. I understand that each pc you install must use a different username, but there must be a much cleaner way to accomplish this, but why are you creating an owner account, only to delete it immediately after... this part doesnt make sense to me.

A couple other options... what if you had cmdlines.txt run the useraccounts.cmd from a floppy, which you update each install? The only caveat to this is that you would need to make sure you insert it after the initial reboot and take it out prior to the final reboot. Sure.. still not completely unattended, but its a hellova lot cleaner than creating an account, then deleting it.

Also, have you looked into this thread? I didnt look all the way through it, but if you can truly do a complete unattended install over the network, than you would have the luxury of being able to change your files, each time you do an install.

Link to comment
Share on other sites

durex,

You've pretty much hit my problem on the head...

Iddeally I want to use cmdlines.txt to create the user account, but cmdlines.txt is on my CD, which means I can't change it for each PC. And having cmdlines.txt ask for the details means the install is not unattended.

I looked at putting cmdlines.txt on a floppy, but unattended is not unattended if you have to take the disk out.....i thought about changing the boot order, but I would have to change it back later, so not perfect (though still an option)

By using my existing cd to crate an account I can then load a batch file from my network (with variables set before I start the install - therefore unattended once started) which creates the correct account, then leaving the CD created account to be deleted.

Using the floppy may still be the best solution (it would also allow 2 or more installs to run at the same time, where the network batch file means I have to alter the file between installs)

The thread on Network Installs is promising, and I have read it before, but installs seem to take a lot longer if you don't have WinPE (which I dont). I may still consider this though.

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