Can't get batch file to input commands into Diskpart

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
WoodrowWilson
Posts: 1
Joined: 21 Jun 2018 14:18

Can't get batch file to input commands into Diskpart

#1 Post by WoodrowWilson » 21 Jun 2018 14:29

Hello, I am trying to create a .bat that uses PsExec to open Diskpart on a server and format a specific drive but the bat file stops running after it opens disk part.
Below is my current .bat:

cd .\NO TOUCH\
.\PsExec.exe \\[IP ADDRESS] -u [USERNAME] -p [PASSWORD] diskpart
list disk
select disk 1
format

When I run the batch it opens up CMD waiting for me to put commands into diskpart

I have tried swapping out "list disk select disk 1 format" with "http:www.google.com" and it does the same thing, no mater what I put after it it just stops at diskpart

Any help?

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Can't get batch file to input commands into Diskpart

#2 Post by Squashman » 21 Jun 2018 14:46

The diskpart commands can be placed in a text file (one command per line) and used as an input file to diskpart.exe:

DiskPart.exe < myscript.txt

or

diskpart /s scriptname.txt

Post Reply