View Full Version : Help with .bat files
Bodkin
01-08-2009, 05:28 AM
Hi, was hoping some one could help me work out how to use a .bat file to run diskpart, and then input some commands.
In other words I want to run diskpart, and then run some commands in diskpart using a .bat file.
Is this possible, and if not is there any outher way of doing this?
Sorry to be a bother. :D
Particle
01-08-2009, 06:21 AM
I don't think you can do this in a batch file since it runs one item at a time, waits for its completion, and then runs another. It will launch diskpart alright, but it'll wait until it is closed before executing the next line. Often times, programs like that can take command-line switches where they will perform the action you want without user input being required. You should check for that. If so, you can make a batch file that will launch the program with the desired options required to perform the task you're after. A lot of times they will tell you what some of their common switches are by using the following:
program.exe /?
program.exe -?
program.exe /help
program.exe -help
You may have to try a few variations. You can also search online. Yup, it looks like someone made a list with explanations (http://www.geocities.com/rick_lively/MANUALS/COMMANDS/D/DISKPART.HTM) available online.
Bodkin
01-08-2009, 08:06 AM
Excellent, cheers for you help.
Particle posted the best way, however it is possible add user input from a batch file. I'm not sure if everything can be done this way, but:
program.exe<input.txt
input.txt is obviously what you'd write as a user. This way you have to predict everything that happens before you run it, if at some point there are 2 possible program behaviours, you've got a problem.
Probably you can do this too, but it's certainly easier to learn C++ than do such things from a batch.