Link to home
Start Free TrialLog in
Avatar of ViRoy
ViRoy

asked on

How to use Format.com in DOS


heya ppl, hopefully an easy one here

i have run into a interesting problem and need a switch for format.
im completely redoing a pc for a friend, his pc has usb mouse and keyboard... standard startup disks do not have usb support and i do not know how to add that functionality.

so im having the autoexec do all my typing for me.
now i need to format the c:\ and of course you get a confirmation prompt for yes/no after typing "format /Q /c:" (im doing quick format to save time)

well i cannot subvert the confirmation prompt!! and since the usb keyboard does not work in dos so i cannot get around it.
i thought the switch to avoid that was /Y but apparently not.

ive tried  --  format c: /Y /YES -Y -YES \Y \YES |Y |YES /P /PROCEED
but everyone will prompt me.
----------------------------------

now ideally i would rather get the usb keyboard working as i should really fdisk it too, but im not sure how to add the usb support to the bootdisk.
now i did check bootdisk.com and found support for usb mice but nothing pertaining to keyboards

please help i will be completing this project tonight, if i cannot get an answer by tonight i probably will not need it however i would like to know the format switch to avoid confirmation so i can add this to my notes.
thx


ASKER CERTIFIED SOLUTION
Avatar of A Syscokid
A Syscokid

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ViRoy
ViRoy

ASKER

hmm, im will write it down and try it but..

i think echo y| format c:
would change the return of the command, not the operand.

and when you <y.txt --- i think that will write the results... to y.txt and not pull from it?
ive never heard of a "hard return"
i just thought of something i wonder if it would work. the ascii for enter is <alt-269> which makes ctrl-m
wonder if i can use that

Avatar of ViRoy

ASKER


WOW thats cool,
i dont have the ability to try it right now, maybe if you have a partition to test on but....

i used to make my file inventory lists by using "dir *.* /s >inventory.txt" and that would write the results to inventory.txt
well i made a file, text.txt and wrote inside of it "text.*" and then typed "DIR <TEXT.TXT" and it gave me the results of text.* !!!

thats pretty cool i had no idea i could use that in reverse!
now im pretty sure that will work with format, cant tell ya till tomorrow though.

also, any idea what you would call those kinda parameters (< > |) so i can maybe find a comprehensive list?
I have used:
echo y | format C:
with good results. (for unattended basic DOS installs).

A PS/2 KB can't be that expensive, though, can it?
/RID
Thanks for confirming on the echo | y, rid.

ViRoy, yeah, > writes to a file and < reads from it. I don't know that they're called parameters, though.  I think > and < are referred to as redirection symbols, and are intrinsic to DOS.
www.calweb.com/~webspace/batch will give you DOS basic batch tutorials:

What are those |<>@ symbols for?
Use the "pipe" character "|" (the vertical bar) to send the output from a command into the input
of another command. For example:
type test.txt | program.exe
That would send the output of the "type" command into the input of the "program.exe" command. The "type" command in this case would be putting out the contents of the file "test.txt". The "program.exe" would (in theory) accept that as it's input instead of accepting input from the keyboard. Use redirection characters ">" and "<" to send output between files and programs. Notice the difference? The pipe sends stuff between two PROGRAMS. Redirection is between a program and a FILE. The redirection arrow lets you know what direction the data is flowing. For example:
program.exe > test.txt
would take the output of "program.exe" and put it in the file "test.txt" INSTEAD of displaying it on the screen. The data flows out of the program "program.exe" and into the file "test.txt". On the other hand:
program.exe < test.txt
Would cause "program.exe" to use "test.txt" as it's input INSTEAD of taking input from the keyboard. The data flows out of the file "test.txt" into the program "program.exe". So these two lines are different ways of doing the same thing:
type test.txt | program.exe
program.exe < test.txt
The both end up telling "program.exe" to use the data in "test.txt" for input instead of using the keyboard. The difference between ">" and ">>" is that ">" 
normally creates a new file, replacing what was there, while ">>" just adds to the end of the file (If the file doesn't already exist, it will be created). You can even use redirection in non-intuitive order and it still works. For example, these two lines do the same thing:
program.exe > test.txt
> test.txt program.exe
Why do it the second way? Sometimes the second way looks neater when you have lots of  program commands going into a single file.
The "@" symbol can be put on the beginning of any command to stop the command from appearing on the screen. Any output from the program goes to the screen, but the command itself doesn't. For example, on a "dir" command, I only want to see a list of files. I do NOT want to see the command "dir".  Normally, you can turn off all screen echoes by using the "echo off" command. So anything after the "echo off" command only shows program output. Unfortunately, the echo command still gets echoed! However, if you put an @ sign in front of the echo command, it turns off the echo from the echo command. That's why most batch files start with this:
@echo off
Avatar of ViRoy

ASKER


rid: lol i suppose they are pretty cheap, but considering i have a 50 foot pile of them at my house i cant bring myself to buy one just for a format heheh

well thanx for the help, you 2 sound pretty confident of the "echo y | format C:"
i was thinkin about it because i thought echo would do nothing more than work with the appearance of command line output but i suppose if you piped a y to format.....
i also origionally though pipe would only goto a stdout like lpt or com.
cant believe im forgetting dos so much, although it has been atleast 4 years since i needed something this low level in dos.

anyways, i will definatley get back on this.. probably monday :)

oh yea, would anyone happen to have a detailed list on usage of | < > and any others?
Check the BIOS - there should be an option to enable legacy USB support - enable it.

This is to support keyboards and mice after POSTing.
This procedure SHOULD work in theory, but for obvious reasons, I am NOT about to test it because I don't have a spare empty hard drive to play with.  In your case you HAVE, so you may as well try this on a SPARE Windows 98 boot floppy. DON'T Do it unless you have a spare one!!!

FORMAT <drive:> /AUTOTEST

Checks for the existing format of your disk, and then proceeds with an UNATTENDED FORMAT.

DOES NOT prompt for a volume label
NO delay: NO user intervention
Ends WITHOUT pausing
After completion, it DOES display disk space statistics
Works on BOTH hard and floppy drives.

On any operational computer, look at the contents of your SPARE boot floppy.
Find AUTOEXEC.BAT and open in NotePad. (DON'T Double-click on it - Right-Click and select "Edit" to open in NotePad).

Select the ENIRE contents and paste the following modified contents in there to overwrite everything, then save it:

@ECHO OFF
set EXPAND=YES
SET DIRCMD=/O:N
set LglDrv=27 * 26 Z 25 Y 24 X 23 W 22 V 21 U 20 T 19 S 18 R 17 Q 16 P 15
set LglDrv=%LglDrv% O 14 N 13 M 12 L 11 K 10 J 9 I 8 H 7 G 6 F 5 E 4 D 3 C
cls
call setramd.bat %LglDrv%
set temp=c:\
set tmp=c:\
path=%RAMD%:\;a:\;%CDROM%:\
copy command.com %RAMD%:\ > NUL
set comspec=%RAMD%:\command.com
copy extract.exe %RAMD%:\ > NUL

%RAMD%:\extract /y /e /l %RAMD%: ebd.cab > NUL
COPY %RAMD%\RESTART.COM  a:\RESTART.COM

LH %RAMD%:\MSCDEX.EXE /D:mscd001 /L:%CDROM%

IF EXIST C:\AUTOEXEC.BAT GOTO :WIPE

E:\SETUP.EXE /ie /im /is /iv /nr
GOTO BYE

:WIPE
FORMAT C: /AUTOTEST
GOTO QUIT

:QUIT
set CDROM=
set LglDrv=
RESTART

:BYE
exit

OK, now do the same with a:\CONFIG.SYS (ie. Shift + Right-Click > Open With > Uncheck the little "always use this program...." box > scroll to NotePad > double-click).

Make the following modifications to the file:

[menu]
menuitem=CD, CD-ROM support will be automatically selected
menuitem=NOCD, Ignore this option
menuitem=HELP, Ignore this option
menudefault=CD,10
menucolor=7,0

That's the only section to amend.

OK, now here's my theory:

Boot to the floppy and it will read AUTOEXEC.BAT.

This firstly calls the file a:\setramd.bat and tells it to find out which drives are which.  It returns the drive letters to autoexec.bat which then adds them to "variables" that it can refer to later eg. %CDROM% and %RAMD%.

%RAMD% is the temporary "drive" that is created on your system drive.  It is a "virtual drive" which will adopt the drive letter next up from your last hard drive partition.  You will have been aware of this happening when the boot floppy informed you "Diagnostics tools successfully loaded to Drive %RAMD%".  The variable is replaced by the drive letter.

It now copies command.com into the RamDrive and sets it up as your DOS system drive.

copy command.com %RAMD%:\ > NUL
set comspec=%RAMD%:\command.com

Now it  copies EXTRACT.EXE to this RamDrive

copy extract.exe %RAMD%:\ > NUL

It now uses EXTRACT.EXE to extract the files from a:\ebd.cab into the RamDrive alongside EXTRACT.EXE

%RAMD%:\extract /y /e /l %RAMD%: ebd.cab > NUL

It also extracts the file RESTART.COM to the RamDrive.

This file has only one use.  If an error occurs in a normal boot floppy, it will force a reboot.  In this case, the hard drive is going to be wiped, so I've decided to grab this file and copy it onto the floppy where I will use it.

COPY %RAMD%\RESTART.COM  a:\RESTART.COM

Now the CD Rom driver is loaded and the normal boot floppy would tell you what your CD Rom's Drive Letter is.  In this case, I am assuming that you will be able to work this out based on what I said above.  If you expect it to be anything other than E:\, then you should amend the appropriate line in a:\autoexec.bat which will follow here.

LH %RAMD%:\MSCDEX.EXE /D:mscd001 /L:%CDROM%

Alright, so we've now got to the line:

IF EXIST C:\AUTOEXEC.BAT GOTO :WIPE

I have deduced that the hard drive you are intending to format will have the file C:\AUTOEXEC.BAT already on it from the existing operating system.  My intention here is that, when the system boots to this floppy the first time around, it will see autoexec.bat and jump to the FORMAT command.

:WIPE
CALL FORMAT C: /AUTOTEST
GOTO QUIT

Now, here's the unknown part and what I HOPE will happen.  When another program is initiated from a batch file using the "CALL" command, it will stay open and wait for control to be returned to it once that process ceases.  You will see this when "Setramd.bat" is called near the start of autoexec.bat  "call setramd.bat %LglDrv%".

So, I am assuming that control will return here again, and then be forced to jump to the :QUIT label.

:QUIT
set CDROM=
set LglDrv=
RESTART

This simply unsets any variable names that were created and, because we are still effectively in the A:\ Drive, the command RESTART.COM is run to force a reboot.

This time, when it reboots and reaches:

IF EXIST C:\AUTOEXEC.BAT GOTO :WIPE

it won't find anything, so the process just falls right through to the SETUP command.  The flow SHOULD now bypass the RESTART command to the :BYE label and just end autoexec.bat as the installation now takes over.

E:\SETUP.EXE /ie /im /is /iv /nr
GOTO BYE

:BYE
exit

I don't even think it will get as far as this, but it does bypass RESTART.

The SETUP.EXE options are:

/ie  Skip the Startup Disk screen
/im  Skip the check for low conventional memory
/is  Do not run ScanDisk
/iv  Do not display billboards
/nr  Skips the registry check

and this makes installation a bit faster, but less interesting if you like watching all the fantastic "billboard" boasts made by Microsoft.

Alright so far, in theory.  Now for the brief section that is amended in CONFIG.SYS.

As we have seen already, autoexec.bat calls "Setramd.bat" for details of the drive letters.  You won't be altering Setramd.bat here but just to explain things, there is a sequence of events where "config.sys" displays a menu of boot options.  It is from this option that a normal boot floppy knows what choice you have made.  On a standard boot floppy this choice is interpreted by the lines:

IF "%config%"=="NOCD" GOTO QUIT
IF "%config%"=="HELP" GOTO HELP

In this case I have removed the "Helpfile" and "NoCD" options from autoexec.bat because I want config.sys to default to booting WITH CD-Rom support.  Take a look at the [boot] section of the amended config.sys file again.

[menu]
menuitem=CD, CD-ROM support will be automatically selected
menuitem=NOCD, Ignore this option
menuitem=HELP, Ignore this option
menudefault=CD,10
menucolor=7,0

The line "menudefault=CD,10" means it will wait 10 seconds for input before defaulting to the "Boot with CD Support" option and return control to the appropriate section of autoexec.bat.

That's my theory over, and you are welcome to try this, but no guarantees.

The problem will come when you are asked for details during setup.  You can actually automate the process a whole lot more so that there is very little or no user interaction required.  This is the type of installation used by Systems Administrators in Windows NT who place "answers" in a file that is consulted during the installation as it gets to each section, but this is another ball game.

Bill
> standard startup disks do not have usb support and i do not know how to add that functionality.
You should check the bios for "USB legacy mode" if it has that functionality, enable it and the USB devices will work in dos.

LucF
http://www.stefan2000.com/darkehorse/PC/DOS/Drivers/USB/

http://www.bootdisk.com/readme.htm#howto
see section titled USB Mouse In DOS

http://www.freedos.org/freedos/news/technote/179.html

"I discovered that if you put the "hidusb.sys" file on your boot floppy and load it at the A: prompt in DOS, the USB mouse will then work in [DOS]. I figured this out when I tried to use a USB mouse in WIN98SE with [DOS-level] Drive Image and discovered that the PS2 mouse driver wouldn't work.

Hidusb.sys is actually a Microsoft USB driver originally from Win98 but included in later Windows versions, too: Just search your system for the file, and it probably will be there"

and, as the others have mentioned "BIOS Legacy USB Support", this explains how it is achieved.
@echo off
EXTRACT /Y /A CDrom:\win98\BASE4.CAB Hidusb.sys /L c:\windows\desktop
exit
try format c: /q/u/autotest

q is for quick
u is for unconditional
autotest cuts out the are you sure stuff etc.

hope this helps,
stuart.
Avatar of ViRoy

ASKER


echo y| format c:

that worked, i had to strip the label as it kept giving me "inavlid label entered" errors.

also, billDL: i did read that article but didnt seem to work for me.
I wonder if, next time you have to do this, you can bypass that by using the /V: switch, e.g.

echo y| format c: /V:

to give it a blank label (or entering a volume label, if appropriate).
Avatar of ViRoy

ASKER

i tried that and it drove me nuts! it does not work with the /V switch... it only works when it has no label at all. weird but what can you expect from M$-DOS i guess huh? lol
ViRoy, pity about the usb mouse driver tip.  I hoped it would work, but I couldn't find a suggestion for loading a usb keyboard driver.

Did you try my my batch file?  Obviously I hadn't tried it after I wrote it, but I am curious as to whether it worked.
Did you try turning on Dos support for USB keyboard devices in the BIOS?