Jump to content

Dos Batch File To Get User Input


Recommended Posts

Hi all,

thanks to these boards I've created a nice unattended CD with WPI to install applications afterwards. But I still have one little problem.

This CD will be used by the company I'm currently working for, meaning this CD will be used on a lot of different pc's all on the same network.

Because of this I would have to edit the username/computername afterwards but even then the productkey would still be the same(we still have a lot of OEM key's) so this is not an option.

So to prevent this I made a small batch file to be run from a bootable floppy disk which asks for user input and then creates an answer file, afterwards the setup should run.

Here is the current batch file:

@ECHO OFF


rem ---------------------------------------------
rem USER INPUT
rem ---------------------------------------------
INPUT "enter productkey:" productkey
INPUT "enter username:" username
INPUT "enter computername:" computername

rem ---------------------------------------------
rem REMOVE OLD ANSWER FILE
rem ---------------------------------------------

DEL a:\WINNT.SIF

rem ---------------------------------------------
rem WRITE NEW ANSWER FILE
rem ---------------------------------------------
ECHO;SetupMgrTag >>a:\WINNT.SIF
ECHO [Data] >>a:\WINNT.SIF
ECHO     AutoPartition=1 >>a:\WINNT.SIF
ECHO     MsDosInitiated="0" >>a:\WINNT.SIF
ECHO     UnattendedInstall="Yes" >>a:\WINNT.SIF
ECHO.  >>a:\WINNT.SIF
ECHO [Unattended] >>a:\WINNT.SIF
ECHO     UnattendMode=FullUnattended >>a:\WINNT.SIF
ECHO     OemSkipEula=Yes >>a:\WINNT.SIF
ECHO     OemPreinstall=YES >>a:\WINNT.SIF
ECHO     TargetPath=\WINDOWS >>a:\WINNT.SIF
ECHO     UnattendSwitch="yes" >>a:\WINNT.SIF
ECHO.  >>a:\WINNT.SIF
ECHO [GuiUnattended] >>a:\WINNT.SIF
ECHO     AdminPassword="xxxxxx" >>a:\WINNT.SIF
ECHO     EncryptedAdminPassword=NO >>a:\WINNT.SIF
ECHO     AutoLogon=Yes >>a:\WINNT.SIF
ECHO     AutoLogonCount=1 >>a:\WINNT.SIF
ECHO     OEMSkipRegional=1 >>a:\WINNT.SIF
ECHO     TimeZone=110 >>a:\WINNT.SIF
ECHO     OemSkipWelcome=1 >>a:\WINNT.SIF
ECHO.  >>a:\WINNT.SIF
ECHO [UserData] >>a:\WINNT.SIF
ECHO     ProductKey=%productkey% >>a:\WINNT.SIF
ECHO     FullName=%username% >>a:\WINNT.SIF
ECHO     OrgName="Koster" >>a:\WINNT.SIF
ECHO     ComputerName=%computername% >>a:\WINNT.SIF
ECHO.  >>a:\WINNT.SIF
ECHO [Display] >>a:\WINNT.SIF
ECHO     BitsPerPel=16 >>a:\WINNT.SIF
ECHO     Xresolution=1024 >>a:\WINNT.SIF
ECHO     YResolution=768 >>a:\WINNT.SIF
ECHO     Vrefresh=70 >>a:\WINNT.SIF
ECHO.  >>a:\WINNT.SIF
ECHO [TapiLocation] >>a:\WINNT.SIF
ECHO     CountryCode=31 >>a:\WINNT.SIF
ECHO.  >>a:\WINNT.SIF
ECHO [RegionalSettings] >>a:\WINNT.SIF
ECHO     LanguageGroup=1 >>a:\WINNT.SIF
ECHO.  >>a:\WINNT.SIF
ECHO [Branding] >>a:\WINNT.SIF
ECHO     BrandIEUsingUnattended=Yes >>a:\WINNT.SIF
ECHO.  >>a:\WINNT.SIF
ECHO [Proxy] >>a:\WINNT.SIF
ECHO     Proxy_Enable=1 >>a:\WINNT.SIF
ECHO     Use_Same_Proxy=1 >>a:\WINNT.SIF
ECHO     HTTP_Proxy_Server=winroute:3128 >>a:\WINNT.SIF
ECHO.  >>a:\WINNT.SIF
ECHO [Identification] >>a:\WINNT.SIF
ECHO     JoinDomain=Koster >>a:\WINNT.SIF
ECHO.  >>a:\WINNT.SIF
ECHO [Networking] >>a:\WINNT.SIF
ECHO     InstallDefaultComponents=Yes >>a:\WINNT.SIF
ECHO. >>a:\WINNT.SIF
ECHO [GuiRunOnce] >>a:\WINNT.SIF
ECHO  %systemdrive%\install\wpi\wpi.hta >>a:\WINNT.SIF


rem ---------------------------------------------
rem START INSTALLATION
rem ---------------------------------------------
rem D:\i386\WINNT.EXE

As you can see I put a REM before the setup command, this is because when the setup should start running it gives me an error that it doesn't know where to put the windows XP install file(probably because of the ramdisk the bootdisk created on c:\)

So I thought I'd be smart and get the input put it in the answer file then reboot and start the install from CD(requires me to eject the floppy for a while but that's not THAT big a deal) However, I have not been able to find any reboot command for dos.

So in short my question is, does anyone know how to run the setup after inputting the commands to the answer file on the floppy drive. Maybe there is some other way to do this that I don't know but this is the only option I could think about.

Any help would be appreciated

Link to comment
Share on other sites


Here This Should Help You

I Made It Based On Your Post

@ECHO OFF
cls && mode 55,5 && Color F1
Title Add User Info To Winnt.sif

:UserProduckey
cls && Color F1
echo.
echo Please Enter Windows Product Key
set /p Key= Here -^>
cls && Color 1f
echo.
echo %key%
ping -n 2 127.0.0.1>nul

:Username
cls && Color F1
echo.
echo Please Enter A User Name
set /p Uname= Here -^>
cls && Color 1f
echo.
echo %Uname%
ping -n 2 127.0.0.1>nul

:Computername
cls && Color F1
echo.
echo Please Enter A Computer Name
set /p Cname= Here -^>
cls && Color 1f
echo.
echo %Cname%
ping -n 2 127.0.0.1>nul

cls && Color F1
Title OutPut The Sif
echo.
echo Processing...
if exist a:\WINNT.SIF DEL a:\WINNT.SIF
ping -n 1 127.0.0.1>nul
rem ---------------------------------------------
rem WRITE NEW ANSWER FILE
rem ---------------------------------------------
ECHO;SetupMgrTag >>a:\WINNT.SIF
ECHO [Data] >>a:\WINNT.SIF
ECHO     AutoPartition=1 >>a:\WINNT.SIF
ECHO     MsDosInitiated="0" >>a:\WINNT.SIF
ECHO     UnattendedInstall="Yes" >>a:\WINNT.SIF
ECHO.  >>a:\WINNT.SIF
ECHO [Unattended] >>a:\WINNT.SIF
ECHO     UnattendMode=FullUnattended >>a:\WINNT.SIF
ECHO     OemSkipEula=Yes >>a:\WINNT.SIF
ECHO     OemPreinstall=YES >>a:\WINNT.SIF
ECHO     TargetPath=\WINDOWS >>a:\WINNT.SIF
ECHO     UnattendSwitch="yes" >>a:\WINNT.SIF
ECHO.  >>a:\WINNT.SIF
ECHO [GuiUnattended] >>a:\WINNT.SIF
ECHO     AdminPassword="xxxxxx" >>a:\WINNT.SIF
ECHO     EncryptedAdminPassword=NO >>a:\WINNT.SIF
ECHO     AutoLogon=Yes >>a:\WINNT.SIF
ECHO     AutoLogonCount=1 >>a:\WINNT.SIF
ECHO     OEMSkipRegional=1 >>a:\WINNT.SIF
ECHO     TimeZone=110 >>a:\WINNT.SIF
ECHO     OemSkipWelcome=1 >>a:\WINNT.SIF
ECHO.  >>a:\WINNT.SIF
ECHO [UserData] >>a:\WINNT.SIF
ECHO     ProductKey=%key% >>a:\WINNT.SIF
ECHO     FullName=%Uname% >>a:\WINNT.SIF
ECHO     OrgName="Koster" >>a:\WINNT.SIF
ECHO     ComputerName=%Cname% >>a:\WINNT.SIF
ECHO.  >>a:\WINNT.SIF
ECHO [Display] >>a:\WINNT.SIF
ECHO     BitsPerPel=16 >>a:\WINNT.SIF
ECHO     Xresolution=1024 >>a:\WINNT.SIF
ECHO     YResolution=768 >>a:\WINNT.SIF
ECHO     Vrefresh=70 >>a:\WINNT.SIF
ECHO.  >>a:\WINNT.SIF
ECHO [TapiLocation] >>a:\WINNT.SIF
ECHO     CountryCode=31 >>a:\WINNT.SIF
ECHO.  >>a:\WINNT.SIF
ECHO [RegionalSettings] >>a:\WINNT.SIF
ECHO     LanguageGroup=1 >>a:\WINNT.SIF
ECHO.  >>a:\WINNT.SIF
ECHO [Branding] >>a:\WINNT.SIF
ECHO     BrandIEUsingUnattended=Yes >>a:\WINNT.SIF
ECHO.  >>a:\WINNT.SIF
ECHO [Proxy] >>a:\WINNT.SIF
ECHO     Proxy_Enable=1 >>a:\WINNT.SIF
ECHO     Use_Same_Proxy=1 >>a:\WINNT.SIF
ECHO     HTTP_Proxy_Server=winroute:3128 >>a:\WINNT.SIF
ECHO.  >>a:\WINNT.SIF
ECHO [Identification] >>a:\WINNT.SIF
ECHO     JoinDomain=Koster >>a:\WINNT.SIF
ECHO.  >>a:\WINNT.SIF
ECHO [Networking] >>a:\WINNT.SIF
ECHO     InstallDefaultComponents=Yes >>a:\WINNT.SIF
ECHO. >>a:\WINNT.SIF
ECHO [GuiRunOnce] >>a:\WINNT.SIF
ECHO  %systemdrive%\install\wpi\wpi.hta >>a:\WINNT.SIF
ping -n 1 127.0.0.1>nul

Link to comment
Share on other sites

Oke i can see why you are doing this,

or cant i?

i figured you wanted to be able to do this UA- install, and

Not have to wait for the GUI-Setup to enter your password????

Because else you could have just leave those 2 values

( licencekey and computer name) undefined,

and your setup would have asked you for them...

so if this is the case... i'd say gotya...

But the way i see this,

> you might want to concider that flopy disk are not to efficient

and breake or get lost easely...

it would be easyer to

pre-format you Hdisk, for exampe using a tool like

'partionmagic for DOS' after that, run your batch file

and put the created awnser .file on your %systemdrive% and

Set you filesystem option in winnt.sif to 'leave alone'

but if you where to do this you'd stil nead to run winnt.exe

in MS-mode to be able to pass the location of winnt.sif

Running Windows NTxxx setup in dosmode isnt the best

and certainly not the fastest way as we probebly all know...

My guess would be to try and change txtsetup.sif to run your batch file

(im not realy sure it this can do the trick

yet i cant think of a reason why it shouldn't either,

(look at the drivers from cd section why i think it is possible))

If indead posible you'd now have the best of both sides.

(not running NTsetup in dos-mode,

and being able to set your own OEM-keys and machine name

a bit sooner than in a normal windows setup...

(and without the hassle of a floppydisk)...

If anyone wants to try...

I, too, would be curious to the results,..

Link to comment
Share on other sites

You just need to specify where the WINNT.SIF file is when you start WINNT. IT only reads it at the very beginning (you don't need to have the floppy in for the rest of the install cycle.

I use the following:

@d:\Install\WinXP\i386\winnt /s:d:\Install\WinXP\i386 /u:d:\batfiles\XPAPPS.sif

Just put your path and filename after /u: and you'll be fine.

JP

Link to comment
Share on other sites

THanks for all the replies, looks like I have some new stuff to try =]

Here This Should Help You

I Made It Based On Your Post

...

batch file snipped

Hmm, doesn't this do the same my batch file did only a bit prettier or am I missing something? Still gonna try it of course =]
I have a attached a simple application - REBOOT.COM

It will only work in a 16-bit PURE Dos-mode environment..

COMMAND : REBOOT .. thats all

Hope this works for u

Looking good, I'll see if I can test it on my own pc this weekend. I'll need to put my floppy drive back into my pc then though o_O

Oke i can see why you are doing this,

or cant i?

i figured you wanted to be able to do this UA- install, and

Not have to wait for the GUI-Setup to enter your password????

Because else you could have just leave those 2 values

( licencekey and computer name) undefined,

and your setup would have asked you for them...

so if this is the case... i'd say gotya...

Yeah I would like to keep it completely unattended apart from entering username, computername and productkey at the start as well as choosing the partition to install on.
My guess would be to try and change txtsetup.sif to run your batch file

(im not realy sure it this can do the trick

yet i cant think of a reason why it shouldn't either,

(look at the drivers from cd section why i think it is possible))

I'll give this a try on monday, I'm gonna try all the new possibilities I've seen in this thread and see what works best =]

Link to comment
Share on other sites

Ok I tried the first reboot.com and it works perfectly!

It's a shame that I will have to take out the floppy and put it back in but it seems to be the only way to get early user input.

I do have one last question though, how do I make the batch file ask for me to press enter to continue before starting the reboot. Otherwise it would just start rebooting when it's done writing to the floppy. This would be easy to miss making it an infinte reboot loop

Once again thanks for all the help, looking forward to using it for the first time on a new pc

Link to comment
Share on other sites

Okie.

Just had a quick browse thru ur request and I'm tired so I might be answering a completely different question!!

:-))

Just wanna check a few details.

1. Will the drive ure installing on already be prepared? eg. fdisk'd or formatted.

2. Is there space on ur floppy for a few tools? maybe 100k

3. Why do u have to take out the floppy and put it back in?

Kev

Kev

Link to comment
Share on other sites

Okie.

Just had a quick browse thru ur request and I'm tired so I might be answering a completely different question!!

:-))

Heh ok =]

Just wanna check a few details.

1. Will the drive ure installing on already be prepared? eg. fdisk'd or formatted.

Already formatted with NTFS. This unattended install will be for both new pc's that just came in, or pc's that just need a new install.
2. Is there space on ur floppy for a few tools? maybe 100k

There still is space left. currently just a bootdisk with input.com, reboot.com and my batch file added

3. Why do u have to take out the floppy and put it back in?

If I don't take it out this is what happens:

I turn on the PC

PC boots from floppy and runs the batch file

I input the needed info and the batch file autoreboots

PC boots from floppy once again

See the problem? =p

SO to get the system to boot from the CD I have to take out the floppy until the install starts, after which I can put it back in so the setup can read the answer file on the floppy

Link to comment
Share on other sites

Soory about the questions.

Just 1 more. Really!!

The command prompt way isn't much different, just adds a tiny amount of extra time. Is this a problem?

My unattended approach means u could get everything done with no rebooting and only removal of floppy once.

If the drive isn't formatted or anything it would mean just 1 reboot and 1 floppy removal.

Slightly more scripting initially but way easier to put ur feet up after.

Kev

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