Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Need to make a batch file to setup 1 partition before OS is installed (Automated Install)

Posted on 2007-11-24
5
Medium Priority
?
1,187 Views
Last Modified: 2010-04-21
I need to make a batch file that can be called from autoexec.bat that will make 1 5GB NTFS partition.  After this action I'm going to be installing Windows XP SP2 fully automated.  Therefore I need to just insert a single CD and have it do all of this.  

So far I do have an idea on how the batch file would work but I'm not exactly sure how ERRORLEVEL works, especially after a computer restarts (Such as after FDISK is executed).  What I need is for this batch file to make the partition, and set it as active (Probably using FDISK) and then format it (Using FORMAT), but not have a continuous loop of it formatting every time it starts and therefore it would need to check to see if it has already fdisk'd and formatted.  Also, a plus would be to delete all partitions at the beginning.  Reference my code snippet for what I'm thinking thus far for a batch file.  One big thing is I don't know 100% how ERRORLEVEL would work because if you restart your computer, I'm not sure if all variables (ERRORLEVELs) are stored in memory (Volatile) or on the HDD (Non-volatile) or however it works.  

In essence, if there isn't a 5GB NTFS partition, this batch file will delete everything on the disk, make a 5GB primary partition, set it as active, restart (If necessary), format the partition, then begin an automated installation of Windows XP SP2 with NO USER INTERACTION NECESSARY.  This disk is meant to be fully automated.  

*****Also, I'm not going to be using any 3rd party programs such as GDISK, delpart, etc.  I will be doing this using ONLY what Windows provides.  
:start
IF NOT ERRORLEVEL 1 goto delete
IF ERRORLEVEL 1 goto part
IF ERRORLEVEL 2 goto format
IF ERRORLEVEL 3 goto end
 
:delete
<Delete all current partitions>
<Somehow return a 1?>
goto start
 
:part
<Make a 5GB primary partition>
<Set that partition as active>
<Somehow return a 2?>
goto start
 
:format
<Format the partition as NTFS>
<Somehow return a 3?>
goto start
 
:end

Open in new window

0
Comment
Question by:JZeolla
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 23

Expert Comment

by:Erik Bjers
ID: 20342651
You want to use diskpart /s <script>

This link will show you how to make the script http://technet2.microsoft.com/windowsserver/en/library/ca099518-dde5-4eac-a1f1-38eff6e3e5091033.mspx?mfr=true

eb
0
 
LVL 6

Accepted Solution

by:
Wallsy earned 400 total points
ID: 20345073
Diskpart is the way to go, but you will want to be booting off a WindowsPE or BartPE disk, not a DOS boot disk. Diskpart is a 32 bit command...

With a 32 bit boot disk you can fdisk, format and use the volume without restarting, and save all of thse problems of tracking where you are in the installation process. Simply choose to boot off the CDROM the first time and everything else is automated.

See http://nu2.nu for Bart PE.

HTH,

Wallsy
0
 
LVL 4

Author Closing Comment

by:JZeolla
ID: 31410767
Perfect.  WindowsPE and diskpart is the solution to my problem, thank you.  
0
 
LVL 4

Author Comment

by:JZeolla
ID: 20347413
Perfect, WindowsPE and Diskpart should work for me.  Thank you.  
0
 
LVL 6

Expert Comment

by:Wallsy
ID: 20348466
Cheers!

Wallsy
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We have adopted the strategy to use Computers in Student Labs as the bulletin boards. The same target can be achieved by using a Login Notice feature in Group policy but it’s not as attractive as graphical wallpapers with message which grabs the att…
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question