Jump to content

DISKPART.EXE and Windows PE 2.0


Phurious

Recommended Posts

Here is my BAT file for a bootable PE 2.0 USB creation:

@ECHO OFF

REM Set our variables so our fingers do not wear down to nubs
REM typing paths. Also helps reduce typos (Ask me how I know).

SET sIMAGEX=C:\Program Files\Windows AIK\Tools\x86
SET sSOURCE=C:\winpe_x86
SET sPETOOLS=C:\Program Files\Windows AIK\Tools\PETools
SET sUSB=F:

REM Creates the DISKPART.EXE script so you do not have to. This
REM Script ASSUMES that your USB drive is the only other HDD on
REM the computer. If you have more than one drive on your PC
REM you are going to have to adjust the first line to reflect the
REM correct disk number.

ECHO SELECT DISK 1 > PEDiskPart.txt
ECHO CLEAN >> PEDiskPart.txt
ECHO CREATE PARTITION PRIMARY >> PEDiskPart.txt
ECHO ASSIGN LETTER=%sUSB% >> PEDiskPart.txt
ECHO SELECT PARTITION 1 >> PEDiskPart.txt
ECHO ACTIVE >> PEDiskPart.txt

ECHO *** Beginning file copy ***
ECHO.
ECHO.

REM Creates the initial build location

%COMSPEC% /c "%sPETOOLS%\copype.cmd" x86 %sSOURCE%

REM Mounts the WINPE.WIM so we may customize the image

"%sIMAGEX%\imagex.exe" /mountrw %sSOURCE%\winpe.wim 1 %sSOURCE%\mount

REM Corrects a Microsoft error that looks for WINLOAD.EXE in the wrong directory

XCOPY "%sSOURCE%\mount\Windows\System32\Boot\*.*" %sSOURCE%\mount\Windows\System32\ /e /y

REM Copies the Servicing folder to the image so we have the extra tools when we
REM boot into PE

XCOPY "C:\Program Files\Windows AIK\Tools\Servicing" c:\winpe_x86\mount\Windows /s

REM This copies the IMAGEX.EXE tool and other required files so we may use when in PE

XCOPY "C:\Program Files\Windows AIK\Tools\x86" c:\winpe_x86\mount\Windows /s /Y

ECHO.
ECHO.
ECHO *** File copy complete ***
ECHO.
ECHO.
PAUSE
CLS

REM I am installing additional drivers for PE 2.0 below. As you can see, I am adding
REM network drivers that cover most all of the PC and laptop hardware we currently
REM use.

ECHO *** Installing additional drivers ***
ECHO.
ECHO.

"%sPETOOLS%\peimg.exe" /inf:C:\lan\3COMA\OEMSETUP.INF %sSOURCE%\Mount\Windows
"%sPETOOLS%\peimg.exe" /inf:C:\lan\3COMB\NET556N5.INF %sSOURCE%\Mount\Windows
"%sPETOOLS%\peimg.exe" /inf:C:\lan\B44\b44win.inf %sSOURCE%\Mount\Windows
"%sPETOOLS%\peimg.exe" /inf:C:\lan\B57\b57win32.inf %sSOURCE%\Mount\Windows
"%sPETOOLS%\peimg.exe" /inf:C:\lan\Intel\E1000325.inf %sSOURCE%\Mount\Windows

ECHO.
ECHO.
ECHO *** Driver installs complete ***
ECHO.
ECHO.
PAUSE

REM You should specify any additional packages you want installed to the off-line image here

ECHO *** Installing specified packages ***
ECHO.
ECHO.
"%sPETOOLS%\peimg.exe" /install=WinPE-HTA-Package %sSOURCE%\Mount\Windows
ECHO.
ECHO.
"%sPETOOLS%\peimg.exe" /install=WinPE-WMI-Package %sSOURCE%\Mount\Windows
ECHO.
ECHO.
"%sPETOOLS%\peimg.exe" /install=WinPE-Scripting-Package %sSOURCE%\Mount\Windows
ECHO.
ECHO.
"%sPETOOLS%\peimg.exe" /install=WinPE-XML-Package %sSOURCE%\Mount\Windows
ECHO.
ECHO.
"%sPETOOLS%\peimg.exe" /install=WinPE-MDAC-Package %sSOURCE%\Mount\Windows
ECHO.
ECHO.
ECHO *** Package installs complete ***
ECHO.
ECHO.
PAUSE
CLS

REM Closes the WINPE.WIM file and copies it to C:\winpe_x86\ISO\sources\boot.wim

ECHO *** Closing and dismounting the image ***
ECHO.
ECHO.
"%sIMAGEX%\imagex.exe" /unmount %sSOURCE%\mount /commit
COPY %sSOURCE%\winpe.wim %sSOURCE%\ISO\sources\boot.wim /Y
ECHO.
ECHO.
ECHO *** Image successfully dismounted and copied to BOOT.WIM ***
ECHO.
ECHO.
PAUSE
CLS

REM The following commands clean the HD, create a primary Partition, and sets it to active. Afterwards, the drive
REM is formatted, and BOOTSECT.EXE is run to add the Vista master boot code to the drive.

ECHO.
ECHO.
ECHO !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!!
ECHO.
ECHO *** Please be aware the next step will erase all the data from your USB drive! ***
ECHO.
ECHO !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!!
ECHO.
ECHO.
PAUSE

ECHO.
ECHO.
DISKPART /s PEDiskPart.txt
FORMAT %sUSB% /FS:NTFS /V:PE_2 /Q /Y
"%sPETOOLS%\x86\bootsect.exe" /nt60 %sUSB%
ECHO.
ECHO.
DEL PEDiskPart.txt
PAUSE
CLS

REM Copies our source files the the newly prepared USB drive.

ECHO.
ECHO.
ECHO *** Copying source files to the USB drive ***
ECHO.
ECHO.
XCOPY %sSOURCE%\iso\*.* /s /e /y /f %sUSB%
ECHO.
ECHO.
ECHO *** Bootable USB drive creation complete ***
ECHO.
ECHO.
PAUSE

If you want to use the format commands at the bottom be aware you need to change the /FS switch from NTFS to FAT32. I made this BAT for a couple of guys at work; that is why I have it generating the diskpart script at the begininng, so they don't have to (Or have it in the wrong place etc.) .

Link to comment
Share on other sites


If you want to use the format commands at the bottom be aware you need to change the /FS switch from NTFS to FAT32. I made this BAT for a couple of guys at work; that is why I have it generating the diskpart script at the begininng, so they don't have to (Or have it in the wrong place etc.) .

(sorry for the delayed response)

Have you tried FAT32? I changed my script to format NTFS and now I can build a bootable USB key from WinXP.

I would prefer to stick with FAT32 but will take what I can get. I also had to change the "Safe Removal Policy" ("Optimize for Performance") to allow the format to NTFS to occur.

Link to comment
Share on other sites

  • 3 years later...
If you want to use the format commands at the bottom be aware you need to change the /FS switch from NTFS to FAT32. I made this BAT for a couple of guys at work; that is why I have it generating the diskpart script at the begininng, so they don't have to (Or have it in the wrong place etc.) .

(sorry for the delayed response)

Have you tried FAT32? I changed my script to format NTFS and now I can build a bootable USB key from WinXP.

I would prefer to stick with FAT32 but will take what I can get. I also had to change the "Safe Removal Policy" ("Optimize for Performance") to allow the format to NTFS to occur.

I know this is old, but the problem is that the XP version of Diskpart does not read USB sticks as "drives" unless the RMB (removable media bit) has not been set. Windows PE 2.0 must have the newer version of Diskpart. I am looking for a download of the Diskpart executable, or I can try to use a third-party program.

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