Jump to content

Recommended Posts


Posted

if you want to do something other than make the full disk a single partition and use somehting other than the default cluster size you will have to partition and format the disk from something like Windows PE or BartPE.

Posted

Hi there, to auto create partitions you will need to boot into winpe or bartpe, then you can run a script like this one to create partitions based on the size of the drive, i run this from my work machine and insert a new HDD to create the partitions for a new user and copy setupfiles needed for xp, then i put the HDD in the new machine and its ready for them to use after setup completes.

you will need to modify it depending on your own needs, if you run this from PE then you will need to change the locations of temp scripts to %tmp%\blah or %userprofile%\blah or it wont work as you wont be able to write to the directory you run this from you will also need to add scripting support for PE all this can be found on the BartPEsite.

just incase anyone was wondering how i can create a new partition C: from my work PC, my system partition is Q:

also if anyone was wondering why i check for a drive bigger than 1GB i once left my UFD in and it wrecked it, lost everything on it...lol...

cmdDiskPart.cmd (save as autorun1.cmd and save into system32 of BartPE)

::REM Set RunTime Variables and Environment
@ECHO OFF
COLOR 0C
TITLE Preparing New Hard Disk Drive
::REM Create Scripts Needed To Run This Script
::REM Input.vbs
ECHO On Error Resume Next > Input.vbs
ECHO. >> Input.vbs
ECHO Const wbemFlagReturnImmediately = ^&h10 >> Input.vbs
ECHO Const wbemFlagForwardOnly = ^&h20 >> Input.vbs
ECHO. >> Input.vbs
ECHO strComputer = "." >> Input.vbs
ECHO Set objWMIService = GetObject("winmgmts:\\" ^& strComputer ^& "\root\CIMV2") >> Input.vbs
ECHO Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly) >> Input.vbs
ECHO. >> Input.vbs
ECHO For Each objItem In colItems >> Input.vbs
ECHO If objItem.index ^> 0 And objitem.Size ^> 1073741824 Then >> Input.vbs <--YOU NEED TO CHANGE INDEX TO EQUAL 0 FOR MAIN DRIVE
ECHO msg = "Disk " ^& objitem.index ^& ";" >> Input.vbs
ECHO x = objitem.Size >> Input.vbs
ECHO a = (x / 100) * 20 >> Input.vbs
ECHO b = (x / 100) * 70 >> Input.vbs
ECHO x = x - (a + b) >> Input.vbs
ECHO msg = msg ^& (a / 1024) \ 1024 ^& ";" >> Input.vbs
ECHO msg = msg ^& (b / 1024) \ 1024 ^& ";" >> Input.vbs
ECHO msg = msg ^& (x / 1024) \ 1024 ^& ";" >> Input.vbs
ECHO Set objFSO = CreateObject("Scripting.FileSystemObject") >> Input.vbs
ECHO strTmpName = "OutPut.txt" >> Input.vbs
ECHO Set objScript = objFSO.CreateTextFile(strTmpName) >> Input.vbs
ECHO objScript.Write msg >> Input.vbs
ECHO objScript.Close >> Input.vbs
ECHO End If >> Input.vbs
ECHO Next >> Input.vbs
::REM Get Drive Size and calculate partition sizes
::REM Set Drive Partition sizes
START /WAIT Input.vbs
IF NOT EXIST Output.txt GOTO ERR
FOR /f "tokens=1,2,3,4 delims=;" %%I in (output.txt) do (
SET HDD=%%I
SET HDD_C=%%J
SET HDD_D=%%K
SET HDD_Z=%%L
)
::REM Create Dynamic Diskpart Script Based On Information Obtained.
FOR /F "tokens=1,2" %%I IN ("%~t0") DO (
SET DT=%%I
SET TM=%%J
)
ECHO REM Diskpart Script Created On %DT% At %TM% > NewDrive.txt
ECHO select %HDD% >> NewDrive.txt
ECHO REM Clean Any Existing Partitions >> NewDrive.txt
ECHO clean >> NewDrive.txt
ECHO REM Create Partition 20%% Of Original Disk Capacity >> NewDrive.txt
ECHO create partition primary size=%HDD_C% >> NewDrive.txt
ECHO assign letter=C >> NewDrive.txt
ECHO REM Create Partition 70%% Of Original Disk Capacity >> NewDrive.txt
ECHO create partition primary size=%HDD_D% >> NewDrive.txt
ECHO assign letter=D >> NewDrive.txt
ECHO REM Create Partition 10%% Of Original Disk Capacity >> NewDrive.txt
ECHO create partition primary >> NewDrive.txt
ECHO assign letter=Z >> NewDrive.txt
ECHO exit >> NewDrive.txt
REM Display Warning
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO ###############################################################################
ECHO ###############################################################################
ECHO ## ##
ECHO ## WARNING!!! ALL DATA WILL BE DESTROYED ##
ECHO ## TO CANCEL OPERATIONS PRESS CTRL + C ##
ECHO ## ##
ECHO ###############################################################################
ECHO ###############################################################################
ECHO.
::REM Allow User Enough Time To Cancel
SLEEP 10
CLS
COLOR 0A
ECHO Creating 3 New Partitions
ECHO.
ECHO Partition 1:
ECHO Size: %HDD_C% MB
ECHO Drive Letter: C:
ECHO File System: NTFS
ECHO.
ECHO Partition 2:
ECHO Size: %HDD_D% MB
ECHO Drive Letter: D:
ECHO File System: NTFS
ECHO.
ECHO Partition 3:
ECHO Size: %HDD_Z% MB
ECHO Drive Letter: Z:
ECHO File System: NTFS
ECHO.
SLEEP 5
CLS
ECHO Please Wait Whilst All Operations Are Completed.
ECHO.
ECHO Starting Diskpart
ECHO.
::REM Starting Operations
Diskpart /S NewDrive.txt
ECHO Diskpart Has Completed
ECHO.
ECHO Formatting New Partitions
ECHO.
FORMAT C: /A:512 /Y /FS:NTFS /V:System
FORMAT D: /A:512 /Y /FS:NTFS /V:Data
FORMAT Z: /A:512 /Y /FS:NTFS /V:Backups
ECHO.
ECHO Completed
ECHO Deleting Temporary Scripts
DEL Input.vbs
DEL NewDrive.txt
DEL Output.txt
SLEEP 3
EXIT
:ERR
ECHO No Drives Larger Than 1GB Found
ECHO Exiting
SLEEP 3
EXIT

Lee.

Posted
Hi there, to auto create partitions you will need to boot into winpe or bartpe, then you can run a script like this one to create partitions based on the size of the drive, i run this from my work machine and insert a new HDD to create the partitions for a new user and copy setupfiles needed for xp, then i put the HDD in the new machine and its ready for them to use after setup completes.

you will need to modify it depending on your own needs, if you run this from PE then you will need to change the locations of temp scripts to %tmp%\blah or %userprofile%\blah or it wont work as you wont be able to write to the directory you run this from you will also need to add scripting support for PE all this can be found on the BartPEsite.

just incase anyone was wondering how i can create a new partition C: from my work PC, my system partition is Q:

also if anyone was wondering why i check for a drive bigger than 1GB i once left my UFD in and it wrecked it, lost everything on it...lol...

cmdDiskPart.cmd (save as autorun1.cmd and save into system32 of BartPE)

::REM Set RunTime Variables and Environment
@ECHO OFF
COLOR 0C
TITLE Preparing New Hard Disk Drive
::REM Create Scripts Needed To Run This Script
::REM Input.vbs
ECHO On Error Resume Next > Input.vbs
ECHO. >> Input.vbs
ECHO Const wbemFlagReturnImmediately = ^&h10 >> Input.vbs
ECHO Const wbemFlagForwardOnly = ^&h20 >> Input.vbs
ECHO. >> Input.vbs
ECHO strComputer = "." >> Input.vbs
ECHO Set objWMIService = GetObject("winmgmts:\\" ^& strComputer ^& "\root\CIMV2") >> Input.vbs
ECHO Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly) >> Input.vbs
ECHO. >> Input.vbs
ECHO For Each objItem In colItems >> Input.vbs
ECHO If objItem.index ^> 0 And objitem.Size ^> 1073741824 Then >> Input.vbs <--YOU NEED TO CHANGE INDEX TO EQUAL 0 FOR MAIN DRIVE
ECHO msg = "Disk " ^& objitem.index ^& ";" >> Input.vbs
ECHO x = objitem.Size >> Input.vbs
ECHO a = (x / 100) * 20 >> Input.vbs
ECHO b = (x / 100) * 70 >> Input.vbs
ECHO x = x - (a + b) >> Input.vbs
ECHO msg = msg ^& (a / 1024) \ 1024 ^& ";" >> Input.vbs
ECHO msg = msg ^& (b / 1024) \ 1024 ^& ";" >> Input.vbs
ECHO msg = msg ^& (x / 1024) \ 1024 ^& ";" >> Input.vbs
ECHO Set objFSO = CreateObject("Scripting.FileSystemObject") >> Input.vbs
ECHO strTmpName = "OutPut.txt" >> Input.vbs
ECHO Set objScript = objFSO.CreateTextFile(strTmpName) >> Input.vbs
ECHO objScript.Write msg >> Input.vbs
ECHO objScript.Close >> Input.vbs
ECHO End If >> Input.vbs
ECHO Next >> Input.vbs
::REM Get Drive Size and calculate partition sizes
::REM Set Drive Partition sizes
START /WAIT Input.vbs
IF NOT EXIST Output.txt GOTO ERR
FOR /f "tokens=1,2,3,4 delims=;" %%I in (output.txt) do (
SET HDD=%%I
SET HDD_C=%%J
SET HDD_D=%%K
SET HDD_Z=%%L
)
::REM Create Dynamic Diskpart Script Based On Information Obtained.
FOR /F "tokens=1,2" %%I IN ("%~t0") DO (
SET DT=%%I
SET TM=%%J
)
ECHO REM Diskpart Script Created On %DT% At %TM% > NewDrive.txt
ECHO select %HDD% >> NewDrive.txt
ECHO REM Clean Any Existing Partitions >> NewDrive.txt
ECHO clean >> NewDrive.txt
ECHO REM Create Partition 20%% Of Original Disk Capacity >> NewDrive.txt
ECHO create partition primary size=%HDD_C% >> NewDrive.txt
ECHO assign letter=C >> NewDrive.txt
ECHO REM Create Partition 70%% Of Original Disk Capacity >> NewDrive.txt
ECHO create partition primary size=%HDD_D% >> NewDrive.txt
ECHO assign letter=D >> NewDrive.txt
ECHO REM Create Partition 10%% Of Original Disk Capacity >> NewDrive.txt
ECHO create partition primary >> NewDrive.txt
ECHO assign letter=Z >> NewDrive.txt
ECHO exit >> NewDrive.txt
REM Display Warning
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO ###############################################################################
ECHO ###############################################################################
ECHO ## ##
ECHO ## WARNING!!! ALL DATA WILL BE DESTROYED ##
ECHO ## TO CANCEL OPERATIONS PRESS CTRL + C ##
ECHO ## ##
ECHO ###############################################################################
ECHO ###############################################################################
ECHO.
::REM Allow User Enough Time To Cancel
SLEEP 10
CLS
COLOR 0A
ECHO Creating 3 New Partitions
ECHO.
ECHO Partition 1:
ECHO Size: %HDD_C% MB
ECHO Drive Letter: C:
ECHO File System: NTFS
ECHO.
ECHO Partition 2:
ECHO Size: %HDD_D% MB
ECHO Drive Letter: D:
ECHO File System: NTFS
ECHO.
ECHO Partition 3:
ECHO Size: %HDD_Z% MB
ECHO Drive Letter: Z:
ECHO File System: NTFS
ECHO.
SLEEP 5
CLS
ECHO Please Wait Whilst All Operations Are Completed.
ECHO.
ECHO Starting Diskpart
ECHO.
::REM Starting Operations
Diskpart /S NewDrive.txt
ECHO Diskpart Has Completed
ECHO.
ECHO Formatting New Partitions
ECHO.
FORMAT C: /A:512 /Y /FS:NTFS /V:System
FORMAT D: /A:512 /Y /FS:NTFS /V:Data
FORMAT Z: /A:512 /Y /FS:NTFS /V:Backups
ECHO.
ECHO Completed
ECHO Deleting Temporary Scripts
DEL Input.vbs
DEL NewDrive.txt
DEL Output.txt
SLEEP 3
EXIT
:ERR
ECHO No Drives Larger Than 1GB Found
ECHO Exiting
SLEEP 3
EXIT

Lee.

thanks dude i will try now

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