OEM part checker script - Replace boot.ini as mid-level task
So I just got done writing a batch script that uses diskpart to analyze the hard drive, determine the number of partitions it has, checks for that pesky OEM partition, and then formats the drive accordingly (with the intent of keeping the OEM part if it exists) Now, this works perfectly for Windows 7, I'm pleased as punch, and I'd like to do the same for XP, but XP bases its mbr on partitions, not volumes.
tl:dr Can I replace the boot.ini as a mid-level task so that it points to the correct partitions?
I suppose I could just test this...
EDIT: Yep as easy as I thought it was. My script is down below if you'd like it.
EDIT2: Turns out some people are having trouble with the script having write access to the drive. The script will still work but you need to pre-create the files that the script calls rather than the script make them. zip them all up then call the batch file.
If anyone wants these zip files ready to go, just pm/email me. I also have a script for those who need to create another partition for the Windows 7 recovery partition
tl:dr Can I replace the boot.ini as a mid-level task so that it points to the correct partitions?
I suppose I could just test this...
EDIT: Yep as easy as I thought it was. My script is down below if you'd like it.
EDIT2: Turns out some people are having trouble with the script having write access to the drive. The script will still work but you need to pre-create the files that the script calls rather than the script make them. zip them all up then call the batch file.
If anyone wants these zip files ready to go, just pm/email me. I also have a script for those who need to create another partition for the Windows 7 recovery partition
0 Comments
[ + ] Show comments
Answers (6)
Please log in to answer
Posted by:
RandomITPro
12 years ago
Ok so this assumes your installing XP or win7 to a single partition and not using win 7s default setup of making a recovery partition and an OS partition. (this can be edited to do so if that's how your org does things) Create each of the following files, zip them up and then call partitionsetup-1part.bat in a new Application pre-install task
partitionsetup-1part.bat
diskpart.txt
nooem.txt
o1p1.txt
o1p2.txt
o1p3.txt
part1checker.txt
part2checker.txt
part3checker.txt
And if your doing xp you'll need to stick this in a batch file. make 2 folders one called "part1" and one called "part2" inside each put a boot.ini file one that references partition(1) or partition(2) as the boot part respectively. Now zip up the batch file and these 2 folders and create a mid-level task where the command is "call whateveryounamedit.bat" obviously only use this mid-level on xp builds.
partitionsetup-1part.bat
@echo off
REM Partition Checker to deploy single partition
diskpart /s part1check.txt
if %errorlevel% EQU 0 set parts=1
diskpart /s part2check.txt
if %errorlevel% EQU 0 set parts=2
diskpart /s part3check.txt
if %errorlevel% EQU 0 set parts=3
if %parts% GEQ 1 GOTO OEMCHECK
ELSE GOTO SKIPOEM
:OEMCHECK
set oem=0
FOR /F "skip=9 tokens=3" %%A IN ('diskpart /s diskpart.txt') DO IF "%%A"=="OEM" set oem=1
:SKIPOEM
if %oem% EQU 0 GOTO NOOEM
:YESOEM
if %parts% EQU 1 diskpart /s o1p1.txt
if %parts% EQU 2 diskpart /s o1p2.txt
if %parts% EQU 3 diskpart /s o1p3.txt
GOTO END
:NOOEM
diskpart /s nooem.txt
:END
diskpart.txt
Sel disk 0
list part
nooem.txt
sel disk 0
clean
create partition primary
active
assign letter="C"
format FS=NTFS QUICK
exit
o1p1.txt
sel disk 0
create partition primary
active
assign letter="C"
format FS=NTFS QUICK
exit
o1p2.txt
sel disk 0
sel part 2
delete partition override
create partition primary
active
assign letter="C"
format FS=NTFS QUICK
exit
o1p3.txt
sel disk 0
sel part 3
delete partition override
sel part 2
delete partition override
create partition primary
active
assign letter="C"
format FS=NTFS QUICK
exit
part1checker.txt
sel disk 0
sel part 1
exit
part2checker.txt
sel disk 0
sel part 2
exit
part3checker.txt
sel disk 0
sel part 3
exit
And if your doing xp you'll need to stick this in a batch file. make 2 folders one called "part1" and one called "part2" inside each put a boot.ini file one that references partition(1) or partition(2) as the boot part respectively. Now zip up the batch file and these 2 folders and create a mid-level task where the command is "call whateveryounamedit.bat" obviously only use this mid-level on xp builds.
@echo off
REM Partition Checker to choose the correct boot.ini
rem create a diskpart check for 2nd partition
echo sel disk 0 >> xp2ndcheck.txt
echo sel part 2 >> xp2ndcheck.txt
diskpart /s xp2ndcheck.txt
if %errorlevel% EQU 0 GOTO PART2
copy ".\part1\boot.ini" "C:\" /Y
GOTO END
:PART2
copy ".\part2\boot.ini" "C:\" /Y
:END
Posted by:
RandomITPro
12 years ago
Posted by:
rjobe
12 years ago
Posted by:
RandomITPro
12 years ago
Posted by:
RandomITPro
12 years ago
heh so turns out batch files aren't allowed to write to the drive due to some permission errors. I've adjusted the code above to show the individual files you'll need to create. Just zip all those up into a zip file, create a new application pre-install task and call the batch file.
If you don't feel like making those files or need code to make 2 partitions you can pm/email me
Sorry for an inconvenience
If you don't feel like making those files or need code to make 2 partitions you can pm/email me
Sorry for an inconvenience
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.