Reputation: 1232
I am creating a visual basic application where I have a Format drive button, which calls cmd to execute the format code as follows:
cmd_str = "cmd.exe /c format " + driveletter + " /q"
Call Shell(cmd_str, vbNormalFocus)
where driveletter is the drive name. The problem is to execute the code, the user has to press ENTER KEY twice. I want the command so that the user don't have to press ENTER , so that I can further make the cmd process as hidden . Any suggetions?
Upvotes: 0
Views: 913
Reputation: 56
pipe the answers to the questions to it:
format c:
asks a question:
The type of the file system is xxx.
WARNING, ALL DATA ON NON-REMOVABLE DISK
DRIVE C: WILL BE LOST!
Proceed with Format (Y/N)?
if the answer is "y" you can do:
echo y | format c:
that will display the question and auto-enter the answer. If you want to suppress all output do you can do:
echo y | format c: > nul
Upvotes: 0