Eliasrd Posted May 16, 2008 Posted May 16, 2008 like the title can i make the partition's to be automatically ?and can i set their "Allocate Unit Size" ?thanks.
IcemanND Posted May 16, 2008 Posted May 16, 2008 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.
devil270975 Posted May 17, 2008 Posted May 17, 2008 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 OFFCOLOR 0CTITLE Preparing New Hard Disk Drive::REM Create Scripts Needed To Run This Script::REM Input.vbsECHO On Error Resume Next > Input.vbsECHO. >> Input.vbsECHO Const wbemFlagReturnImmediately = ^&h10 >> Input.vbsECHO Const wbemFlagForwardOnly = ^&h20 >> Input.vbsECHO. >> Input.vbsECHO strComputer = "." >> Input.vbsECHO Set objWMIService = GetObject("winmgmts:\\" ^& strComputer ^& "\root\CIMV2") >> Input.vbsECHO Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly) >> Input.vbsECHO. >> Input.vbsECHO For Each objItem In colItems >> Input.vbsECHO If objItem.index ^> 0 And objitem.Size ^> 1073741824 Then >> Input.vbs <--YOU NEED TO CHANGE INDEX TO EQUAL 0 FOR MAIN DRIVEECHO msg = "Disk " ^& objitem.index ^& ";" >> Input.vbsECHO x = objitem.Size >> Input.vbsECHO a = (x / 100) * 20 >> Input.vbsECHO b = (x / 100) * 70 >> Input.vbsECHO x = x - (a + b) >> Input.vbsECHO msg = msg ^& (a / 1024) \ 1024 ^& ";" >> Input.vbsECHO msg = msg ^& (b / 1024) \ 1024 ^& ";" >> Input.vbsECHO msg = msg ^& (x / 1024) \ 1024 ^& ";" >> Input.vbsECHO Set objFSO = CreateObject("Scripting.FileSystemObject") >> Input.vbsECHO strTmpName = "OutPut.txt" >> Input.vbsECHO Set objScript = objFSO.CreateTextFile(strTmpName) >> Input.vbsECHO objScript.Write msg >> Input.vbsECHO objScript.Close >> Input.vbsECHO End If >> Input.vbsECHO Next >> Input.vbs::REM Get Drive Size and calculate partition sizes::REM Set Drive Partition sizesSTART /WAIT Input.vbsIF NOT EXIST Output.txt GOTO ERRFOR /f "tokens=1,2,3,4 delims=;" %%I in (output.txt) do (SET HDD=%%ISET HDD_C=%%JSET HDD_D=%%KSET HDD_Z=%%L)::REM Create Dynamic Diskpart Script Based On Information Obtained.FOR /F "tokens=1,2" %%I IN ("%~t0") DO (SET DT=%%ISET TM=%%J)ECHO REM Diskpart Script Created On %DT% At %TM% > NewDrive.txtECHO select %HDD% >> NewDrive.txtECHO REM Clean Any Existing Partitions >> NewDrive.txtECHO clean >> NewDrive.txtECHO REM Create Partition 20%% Of Original Disk Capacity >> NewDrive.txtECHO create partition primary size=%HDD_C% >> NewDrive.txtECHO assign letter=C >> NewDrive.txtECHO REM Create Partition 70%% Of Original Disk Capacity >> NewDrive.txtECHO create partition primary size=%HDD_D% >> NewDrive.txtECHO assign letter=D >> NewDrive.txtECHO REM Create Partition 10%% Of Original Disk Capacity >> NewDrive.txtECHO create partition primary >> NewDrive.txtECHO assign letter=Z >> NewDrive.txtECHO exit >> NewDrive.txtREM Display WarningECHO.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 CancelSLEEP 10CLSCOLOR 0AECHO Creating 3 New PartitionsECHO.ECHO Partition 1:ECHO Size: %HDD_C% MBECHO Drive Letter: C:ECHO File System: NTFSECHO.ECHO Partition 2:ECHO Size: %HDD_D% MBECHO Drive Letter: D:ECHO File System: NTFSECHO.ECHO Partition 3:ECHO Size: %HDD_Z% MBECHO Drive Letter: Z:ECHO File System: NTFSECHO.SLEEP 5CLSECHO Please Wait Whilst All Operations Are Completed.ECHO.ECHO Starting DiskpartECHO.::REM Starting OperationsDiskpart /S NewDrive.txtECHO Diskpart Has CompletedECHO.ECHO Formatting New PartitionsECHO.FORMAT C: /A:512 /Y /FS:NTFS /V:SystemFORMAT D: /A:512 /Y /FS:NTFS /V:DataFORMAT Z: /A:512 /Y /FS:NTFS /V:BackupsECHO.ECHO CompletedECHO Deleting Temporary ScriptsDEL Input.vbsDEL NewDrive.txtDEL Output.txtSLEEP 3EXIT:ERRECHO No Drives Larger Than 1GB FoundECHO ExitingSLEEP 3EXITLee.
Eliasrd Posted May 17, 2008 Author Posted May 17, 2008 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 OFFCOLOR 0CTITLE Preparing New Hard Disk Drive::REM Create Scripts Needed To Run This Script::REM Input.vbsECHO On Error Resume Next > Input.vbsECHO. >> Input.vbsECHO Const wbemFlagReturnImmediately = ^&h10 >> Input.vbsECHO Const wbemFlagForwardOnly = ^&h20 >> Input.vbsECHO. >> Input.vbsECHO strComputer = "." >> Input.vbsECHO Set objWMIService = GetObject("winmgmts:\\" ^& strComputer ^& "\root\CIMV2") >> Input.vbsECHO Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly) >> Input.vbsECHO. >> Input.vbsECHO For Each objItem In colItems >> Input.vbsECHO If objItem.index ^> 0 And objitem.Size ^> 1073741824 Then >> Input.vbs <--YOU NEED TO CHANGE INDEX TO EQUAL 0 FOR MAIN DRIVEECHO msg = "Disk " ^& objitem.index ^& ";" >> Input.vbsECHO x = objitem.Size >> Input.vbsECHO a = (x / 100) * 20 >> Input.vbsECHO b = (x / 100) * 70 >> Input.vbsECHO x = x - (a + b) >> Input.vbsECHO msg = msg ^& (a / 1024) \ 1024 ^& ";" >> Input.vbsECHO msg = msg ^& (b / 1024) \ 1024 ^& ";" >> Input.vbsECHO msg = msg ^& (x / 1024) \ 1024 ^& ";" >> Input.vbsECHO Set objFSO = CreateObject("Scripting.FileSystemObject") >> Input.vbsECHO strTmpName = "OutPut.txt" >> Input.vbsECHO Set objScript = objFSO.CreateTextFile(strTmpName) >> Input.vbsECHO objScript.Write msg >> Input.vbsECHO objScript.Close >> Input.vbsECHO End If >> Input.vbsECHO Next >> Input.vbs::REM Get Drive Size and calculate partition sizes::REM Set Drive Partition sizesSTART /WAIT Input.vbsIF NOT EXIST Output.txt GOTO ERRFOR /f "tokens=1,2,3,4 delims=;" %%I in (output.txt) do (SET HDD=%%ISET HDD_C=%%JSET HDD_D=%%KSET HDD_Z=%%L)::REM Create Dynamic Diskpart Script Based On Information Obtained.FOR /F "tokens=1,2" %%I IN ("%~t0") DO (SET DT=%%ISET TM=%%J)ECHO REM Diskpart Script Created On %DT% At %TM% > NewDrive.txtECHO select %HDD% >> NewDrive.txtECHO REM Clean Any Existing Partitions >> NewDrive.txtECHO clean >> NewDrive.txtECHO REM Create Partition 20%% Of Original Disk Capacity >> NewDrive.txtECHO create partition primary size=%HDD_C% >> NewDrive.txtECHO assign letter=C >> NewDrive.txtECHO REM Create Partition 70%% Of Original Disk Capacity >> NewDrive.txtECHO create partition primary size=%HDD_D% >> NewDrive.txtECHO assign letter=D >> NewDrive.txtECHO REM Create Partition 10%% Of Original Disk Capacity >> NewDrive.txtECHO create partition primary >> NewDrive.txtECHO assign letter=Z >> NewDrive.txtECHO exit >> NewDrive.txtREM Display WarningECHO.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 CancelSLEEP 10CLSCOLOR 0AECHO Creating 3 New PartitionsECHO.ECHO Partition 1:ECHO Size: %HDD_C% MBECHO Drive Letter: C:ECHO File System: NTFSECHO.ECHO Partition 2:ECHO Size: %HDD_D% MBECHO Drive Letter: D:ECHO File System: NTFSECHO.ECHO Partition 3:ECHO Size: %HDD_Z% MBECHO Drive Letter: Z:ECHO File System: NTFSECHO.SLEEP 5CLSECHO Please Wait Whilst All Operations Are Completed.ECHO.ECHO Starting DiskpartECHO.::REM Starting OperationsDiskpart /S NewDrive.txtECHO Diskpart Has CompletedECHO.ECHO Formatting New PartitionsECHO.FORMAT C: /A:512 /Y /FS:NTFS /V:SystemFORMAT D: /A:512 /Y /FS:NTFS /V:DataFORMAT Z: /A:512 /Y /FS:NTFS /V:BackupsECHO.ECHO CompletedECHO Deleting Temporary ScriptsDEL Input.vbsDEL NewDrive.txtDEL Output.txtSLEEP 3EXIT:ERRECHO No Drives Larger Than 1GB FoundECHO ExitingSLEEP 3EXITLee.thanks dude i will try now
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now