Jump to content

Batch file to let choose an answer file


Recommended Posts

Hey everybody :hello:

I created a little batch file to let you choose your answer file before a format.

This file is for those people who install with winnt32.exe (like me :) )

The function of this script is the following:

- Find out the drive letter of the Windows XP CD (cd.txt must be on the root of the CD)

- Ask the user on which drive he wants to install

- Let's the user choose an answer file

- formats the choosen drive

- Installs XP

In order to use winnt32.exe (32-bit application) we need to use WINPE or BARTPE.

Ofcourse I tested this for myself (well, only in CMD not with a format)

What is your opinion about the batch file?

Is there anyway I can improve this? (my batch skills are not that good, so improvements are welcome)

EDIT:

NEW VERSION 15/6/2005

I added the possibility to create your own winnt.sif (at least part of them)

Prepare_windows_install.zip

Edited by erik_demon
Link to comment
Share on other sites


Hmmm, I am thinking about something similar, but still different :)

HTA application, that will let you choose what you want to change and it will modify winnt.sif.

The tool for small companies that are installing computers for clients - they will set everything for unattended installation, but what you cant automate (e.g. company name etc.), they will have ability to set BEFORE installation, not during. So he will run installation, make necessary changes and leave computer.

Link to comment
Share on other sites

First time poster, because I was looking to do this same task. My plans may differ a little from the original poster.

What I'm wanting to do is have the user prompted for some pre-install questions that will edit the winnt.sif file with the appropriate changes. For example, here at the university we use static IPs instead of DHCP. So, having the network settings installed automatically doesn't work too well.

I would like to ask the user if he knows the IP address he will be using at the install that day and then it will add it to the winnt.sif file. Make sense? This would help a lot in the network based tasks, because then everything would be configured and I could perform other tasks such as joining the domain and calling install points for Office 2003.

As it stands now, I have to install XP under the default workgroup settings with no static IP and configure all of that when the installation completes. After which, I can then perform the network tasks mentioned above. It's not too much of a pain, but I would like to automate as much as possible.

Thanks.

Edit

I realize that by doing this, I lose the ability to put the winnt.sif file on the install cd. I would think I would need a boot floppy of some kind that ran a batch file prompting for the answers which in turn would edit the sif file on the floppy.

Link to comment
Share on other sites

  • 2 weeks later...

Sorry for the late response guys, I have been very busy lately :blushing:

@genex

Thanks, about that turtorial. The most import thing is that you understand how to set user imput:

SET Choice=
SET /P Choice="Is this correct? (Y/N)     "
IF NOT '%Choice%'=='' SET Choice=%Choice:~0,1%
IF /I '%Choice%'=='Y' (
GOTO Choose_user
)
IF /I '%Choice%'=='N' (
GOTO Install_drive
)

I find it hard to explain this because I don't know eveything about this to :D

SET /P Choice holds the batch file and asks user imput. If you type Y the variable %Choice% is equal to Y. After this, we use IF to check the value and execute a command (in this case: Goto Choose_user)

That is the most important. If you would like you can change the variable name. You can test it like this:

@ECHO OFF
SET Option=
SET /P Option="Select an option: (1 or 2)    "
IF NOT '%Option%'=='' SET Option=%Option:~0,1%
IF /I '%Option%'=='1' (
ECHO.
ECHO You Selected option 1
Pause
GOTO end
)
IF /I '%Option%'=='2' (
ECHO.
ECHO You Selected option 2
Pause
GOTO end
)

:end

I hope this helps

@Martin Zugec

Good idea! Since I use BARTPE, I believe .HTA support is avaiable. About the support for companies, check out below

@metabaron

That's great, Would you like to share it?

@zxfiles

Hi welcome :hello:

I think I found what you where looking for (and I was looking for it to :P )

Check-out this post

I tested it, and with this method you can created specific parts for your winnt.sif

Edited by erik_demon
Link to comment
Share on other sites

New version available (see first post)

This version is written for my system, so if you want to use it, you need to modify it.

Since my batch skills are not that great, it may be that parts of the script can be optimized. If you see such a part, please comment :D

I tested it and for my system it works great :thumbup

EDIT:

For the winnt.sif creator, credits go to gunsmokingman who designed it (see the link in post nr. 6 )

Thanks :thumbup

Edited by erik_demon
Link to comment
Share on other sites

what would be really cool is if there are a few winnt.sif files that have most of the answers. now, the sif file would will have to be loaded into memory at some point in time right, so why not have it make the changes to the sif file in memory. that way there wouldnt be a need for a floppy. i dont know how this could be mananged, but i think it would be really cool.

either that or a sif file somewhere on the network so it can be changed depending on how the user answers

Link to comment
Share on other sites

sorry for the late answer, I didn't pay attention to the topic :blushing:

I do not completely understand what you mean:

how are you both 'echoing to' and 'deleting from' the optical disk drive?

I believe that you think that I use this for a CD based installed, correct?

If you mean that, it will not work. I install my computer from a second harddrive. On that drive, I can write and delete as much as I like.

You are correct when you say that this won't work with a CD install.

However...

If you change the batch file like this:

ECHO     AutoPartition=1 >>%CDROM%WINNT.SIF

to

ECHO     AutoPartition=1 >>A:\WINNT.SIF

the winnt.sif will be written to a Floppy disk. Then you could modify the batch file to let winnt32.exe find the answer file there

I hope this helps

Edited by erik_demon
Link to comment
Share on other sites

This version is written for my system

<snip>

I tested it and for my system it works great

If
for %%i in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if exist %%i:\cd.txt set CDROM=%%i:

:Install_drive
cls

ECHO Your CD-rom drive is: %CDROM%

then

if exist %CDROM%WINNT.SIF DEL %CDROM%WINNT.SIF
ping -n 1 127.0.0.1>nul
rem ---------------------------------------------
rem WRITE NEW ANSWER FILE
rem ---------------------------------------------
ECHO;SetupMgrTag >>%CDROM%WINNT.SIF
<snip>

You are deleting from and echoing to the optical drive, therefore how did you test it?

Link to comment
Share on other sites

@Yzöwl

You have a point here, this is my misstake. I will explain it :)

My unattended structure at home is so that I am able to install from a CD, from a second harddisk and from a network share.

To not complicate things, to keep everything simpel, I work with only one variable. This variable is %CDROM%.

In my test the file called cd.txt was on my second harddrive ( D:\ ) therfore this harddrive is seen as %CDROM% and the batch file will tell you

Your CD-rom drive is: D: :D

I understand your confusion completely an when I get back from vacation (ah finally :P ) I will change it, because like you stated, it is not possible to write or delete to the optical drive.

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