Reputation: 11
I am trying to create a one bat file with diskpart script to automatize the process of creating volumes. The problem is that I want to pass parameters like this:
diskpart /s "createVolume.bat 500"
Where "500" is a size of volume. Of course, this solution is not working. I was trying to do something like this in bat file:
diskpart
select disk 0
create volume simple size=%1
format quick fs=ntfs label="userTest"
assign letter="T"
But in cmd, it stops on DISKPART>
.
Is there any way to use diskpart with parameters passed to the script?
Upvotes: 0
Views: 4582
Reputation: 67216
Accordingly to the documentation given at this site, this should work:
@echo off
(
echo select disk 0
echo create volume simple size=%1
echo format quick fs=ntfs label="userTest"
echo assign letter="T"
) > script.txt
diskpart /s script.txt
Copy this code into a Batch file, for example createVolume.bat, and then use it this way:
createVolume 500
Upvotes: 2