Batch File Help Windows 7

Trying to Deploy Win7. Need to make a batch file and I need some help. This is what I type in manually right now...

diskpart
select volume 2
format quick fs=ntfs label"win7"
exit
imagex /apply g:\lenovom90zfull.wim 1 d:/
exit

how can I do this with a single batch file? It hangs when I hit the diskpart portion when I make a batch file.
MawayaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lee W, MVPTechnology and Business Process AdvisorCommented:
Why aren't you configuring this with the WAIK and an answer file?
MawayaAuthor Commented:
I'm old school xp. Answer file
isn't what it used to be. didn't know the answer file could erase an existing partition and image over it.

can u help me?
RootsManCommented:
Create a text file, e.g. dpcommands.txt, with the following commands:

     select volume = 2
     format FS=NTFS LABEL="Win 7" quick
     exit

Then modify your batch file to call diskpart with the following parameters:

       diskpart /s dpcommands.txt

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

MawayaAuthor Commented:
Rootsman,

Do I put the other part after the command like so?

diskpart /s dpcommands.txt
imagex /apply g:\lenovom90zfull.wim 1 d:/
exit
RootsManCommented:
Yes, but without the exit command.
Shouldn't you have a backslash after the D: instead of a regular slash to indicate the root for drive D:?
MawayaAuthor Commented:
heh, typo there that's correct. gonna try your suggestion today.
MawayaAuthor Commented:
This helped! And he also corrected my typo!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows 7

From novice to tech pro — start learning today.