Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format a disk

Status
Not open for further replies.

victoryhighway2

Programmer
Jul 18, 2005
42
US
Hello,
I am looking for a way to automatically and silently format a disk from my VB code.

I first looked into SHFormatDrive, but all that opens the standard Windows format disk dialog and requires manual intervention.

I also looked into shelling out to FORMAT.COM, but that isn't working either.

Is there another way of going about this?

Regards,
Geoffrey
 
First, make sure you have all the format parameters you are looking for...

click Start -> Run
Type: %Windir%\Help\ntcmds.chm
Click OK

do a search on Format

then, you can run this using the shell command

Shell "cmd /c Format <Include your command line arguments>"


-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Shell to cmd and use the /c argument. You will need to get the format responses from a text file.
Open a text file (say C:\test.txt) which contains:
(that's Y and a {CR} followed by N and a {CR})
Then from VB:
Code:
Shell("cmd /c format a: /q < c:\test.txt")

The 'cmd /c' says DO IT
The /q is for quick format (omit if you need a full format)
The < C:\test.txt supplies the FORMAT answers

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top