how do I get format to work from the commandline with no prompts?

Posted on 2005-04-25
Last Modified: 2010-04-14
Hey guys,
I have written a batch for 2k3 which shutdowns certain services, runs defrag, and then restarts the services once a day. I am trying to accomplish this same thing with 2000. I have run into a variety of problems. First being that defrag is not supported from the commandline in 2k. No biggie. The work around is to simply quick format the raid device (mail spool) however, I cannot seem to get format to go from the batch file without prompting for the volume label and then a yes no answer. How do I accomplish this?

Worth 500 points.

Question by:richardsimnett
    LVL 57

    Expert Comment

    by:Pete Long
    Hi richardsimnett,
    format /q

    not work?

    LVL 82

    Accepted Solution

    The volume label can be specified with the /v:VolumeLabel switch; as for the prompt, try to pipe an "echo." to the format command. Specify the file system with /fs:NTFS. So the following line should do what you need:
    echo.|format X: /v:VolumeLabel /fs:NTFS /q
    On the other hand: a simple
    rd /s /q "X:\Mail\Spool\Folder"
    should work as well, shouldn't it?
    LVL 12

    Assisted Solution

    Hmm....trickier that is sounds at first.  oBdA's suggestion will *almost* work, but
    - you have to specify ECHO Y (not ECHO .)
    - The volume label must be blank, to avoid having to specify the "old" volume label

    LVL 82

    Expert Comment

    Well, I could only test it with a floppy (on which it worked), I didn't have a spare partition ...
    LVL 12

    Expert Comment

    yeah, it will work when formatting a new partition...but then if you run it a second time it expects you to also enter the "old" label for verification (unless it is blan).
    LVL 32

    Expert Comment

    A workaround might be to just delete all files and folders on that drive with a command like:

     del z:\*.* /f/s/q

    LVL 12

    Expert Comment

    Yes, deleting all the files sounds like a good alternative.

    Author Comment

    Ok... I have done the following which works:

    ECHO Y | format f: /Q
    md f:\spool

    Just deleting the files and directories wont do it, as it doesnt realign the filesystem. (Ideally I would be able to defrag the raid from the command prompt, but thats not an option in win2k). After a few days of running the raid (SCSI 320) performance drops significantly because of the fragmentation of the file system.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
    If you're not part of the solution, you're part of the problem.   Tips on how to secure IoT devices, even the dumbest ones, so they can't be used as part of a DDoS botnet.  Use PRTG Network Monitor as one of the building blocks, to detect unusual…
    This video discusses moving either the default database or any database to a new volume.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now