Solved

Format external drive in using DOS commands in C program

Posted on 2007-03-26
22
252 Views
Last Modified: 2010-04-03
I want to format an external hard drive using a DOS command.  The OS is Win 2003.  The drive letter is 'e:' .  When I try the following syntax I get: "Enter Current Volume Label for Drive E:".

format e: /q /u

I want to do this in a program so I can't have it asking me to enter more data.  We run a C program for a backup strategy and I want to format each external drive before we backup daily.  
0
Comment
Question by:bretthonn13
  • 14
  • 8
22 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 18794165
format e: /q /u /v:Label
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18794168
..where Label is the label name you want to assign it...
0
 

Author Comment

by:bretthonn13
ID: 18794211
nope, it still prompts me to "Enter current volume label for drive E:"
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 67

Expert Comment

by:sirbounty
ID: 18794369
You'll need to change the Label above to something though...did you do this?

format e: /q /u /v:MyLabel
for instance...
0
 

Author Comment

by:bretthonn13
ID: 18794406
sirbounty

yep, it acts as though it doesn't even see that last parameter.  as soon as I type the real label it fires off no problem.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18794416
Hm..

what about

echo myLabel | format e: /v /u
0
 

Author Comment

by:bretthonn13
ID: 18794465
we're getting somewhere.  It then prompts me twice asking tif I wish to proceed with format and then imediately goes to the original command prompt.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18794484
how about

echo MyLabel | form e: /v /u /L:
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18794491
sorry, that should've read

echo myLabel | format e: /u /v:
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18794492
with the /q in there too, if you needed it quickformatted
0
 

Author Comment

by:bretthonn13
ID: 18794902
it still just gets me right back to my prompt.  that is a pipe symbol between the label and format, correct?
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18794912
yes sir.
I wonder if it's due to the unconditional parameter?
try

format e: /q /v:myLabel
or
echo mYLabel | format e: /q /v
0
 

Author Comment

by:bretthonn13
ID: 18794999
sorry, no luck.  
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18795134
Hmm - I don't have a drive to test - but is this because it's ntfs?
0
 

Author Comment

by:bretthonn13
ID: 18795166
It is NTFS for sure.  Do you think that could be the problem?  
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18795185
Ah - I think I know the problem...it's asking for you to verify the current volume label perhaps?

How about this? (does it 'have' to be all one line, or just scripted?)

for /f "tokens=6*" %%a in ('vol e:^|find /i "drive"') do set volname=%%a
echo %volName%|format e: /x /q /u /v:myLabel
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18795191
"Enter Current Volume Label for Drive E:".
is a safeguard against formatting the wrong disk...(supposedly) - so it's asking you to confirm that you know what you're doing basically..

I "think" the above will do it...let me know!
0
 

Author Comment

by:bretthonn13
ID: 18795255
I was doing it in a DOS window so I thought it had to be all on one line???  where do you suggest I put these lines:
for /f "tokens=6*" %%a in ('vol e:^|find /i "drive"') do set volname=%%a
echo %volName%|format e: /x /q /u /v:myLabel

0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18795300
save them (notepad will work) into a single file,
formatmydrive.bat (or something more clever :) - just don't call it format.bat...format's already taken...haha
0
 

Author Comment

by:bretthonn13
ID: 18795349
this is exactly what I typed in my "clever" .bat file....

for /f "tokens=6*" %%a in ('vol e:^|find /i "drive"') do set volname=%%a
echo %volName%|format e: /x /q /u /v:extDRV
PAUSE

...and this is what I get in my comman window:


C:\Documents and Settings\Brett\Desktop>for /F "tokens=6*" %a in ('vol e:|find /
i "drive"') do set volname=%a

C:\Documents and Settings\Brett\Desktop>set volname=extDRV

C:\Documents and Settings\Brett\Desktop>echo extDRV  | format e: /x /q /u /v:ext
DRV
The type of the file system is NTFS.
Enter current volume label for drive E:
WARNING, ALL DATA ON NON-REMOVABLE DISK
DRIVE E: WILL BE LOST!
Proceed with Format (Y/N)?
WARNING, ALL DATA ON NON-REMOVABLE DISK
DRIVE E: WILL BE LOST!
Proceed with Format (Y/N)?
C:\Documents and Settings\Brett\Desktop>PAUSE
Press any key to continue . . .
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 18796217
Wow...things have changed since I did this last... : (
That's a lot of prompts to account for, huh?
Try placing a /y at the end of the format command...format e: /x /q /u /v:NewVolume /y
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18799780
Hooray! (was beginning to think I was just getting 'old' - haha!)
Happy to have helped...glad it worked for you.
Thanx for the grade! :^)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

this article is a guided solution for most of the common server issues in server hardware tasks we are facing in our routine job works. the topics in the following article covered are, 1) dell hardware raidlevel (Perc) 2) adding HDD 3) how t…
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
This video teaches viewers how to encrypt an external drive that requires a password to read and edit the drive. All tasks are done in Disk Utility. Plug in the external drive you wish to encrypt: Make sure all previous data on the drive has been …

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question