The Fabulous BatPower #### #### ### ### ########## ##### ##### ### ### ########## ### ## ## ### ### ### ### ### ## ## ### ### ### ######## ### ### ### ### ### ######## ### # ### ### ### ### ### ### ### ### ### ### ### ## ########## ## ### ## ### ### ## ######## ## ### ## (c) List (MicroSoft's Undocumented Features) Volume 1 Number 7 =============================================================================== 1) ATTRIB ATTRIB , To remove all file attributes, from files in the directory you are in, type: attrib , Works for dos 5 and above... be careful with this one... I haven't tried it with the /s extension. Frank Ganje ATTRIB ,|ECHO Y|DEL *.* I originally put forward the above suggestion. It was a one line command that could delete ALL files in the current directory. But of course there is no point in typing it in at the dos prompt as the person is there to press y at the right time. In a batch file you would naturally split this command in two. "Attrib ," can be used with the /S switch, so if entered in the root directory you could reset _ALL_ attributes of _ALL_ files on the _ENTIRE_ drive. Richard Gallagher Does this really work? I tried a previous suggestion, and it didn't. I don't see the reason to pipe the attrib output to the echo command. Bruce Bowman Worked fine here, took out all the files (system, hidden, read-only), like a dream with no lock up, using MSDos 5.0 Terry Kreft What version of DOS do you have? It works fine with DOS 5. This is one way of stacking multiple commands on one line. It is not really piping the output of attrib to echo. Using the pipe is one way of stacking multiple commands on a line. All the "attrib ," does is reset _ALL_ attributes on _ALL_ files in the current directory. So if you were to run that from the root of your c: drive you would no longer have a bootable drive. Jim Banghart (EDITOR'S NOTE: See the Multiple DOS Commands per Line section for additional information) I use DOS 5 also, and it doesn't always work. I do not recommend this practice. It does attempt to pipe the output of attrib to echo, and thus writes a file to the directory specified by the environment variable TEMP. If you try to run this program in your TEMP directory, you will get a sharing violation. It also actually slows your program, because it has to write and delete a useless file (unless you have your TEMP on a ramdisk). I can't say I see much reason for stacking commands like this - put the commands on separate lines. A character is a character, be it a carriage return or a pipe, and your files will be easier to understand. Try running it in your TEMP directory. You will get a share violation because ATTRIB will write a file to that directory. Better to split the commands on two lines; avoid fostering bad habits. Bruce Bowman This does not work under Desqview. If you want to use it under DOS it can also be shortened to: attrib,|echo y|del. Terry Blount It depends on what directory you run it in. DV hooks the interrupts for fatal errors and sharing violations, so it catches errors better than DOS does. Try running it somewhere other than your TEMP directory, or the directory in which your batch file resides, and it should work okay. Bruce Bowman ATTRIB +H Is there anyway to create a hidden directory on a hard drive? I've since learned that DOS 5.0 ATTRIB can do the same thing from the command line: ATTRIB +h dirname Gary Smith =============================================================================== 2) CALL The DOS 5.0 manual, in the command reference for CALL, states: Syntax: call [drive:][path]filename [batch-parameters] Parameters [drive:][path]filename Specifies the name and location of the batch program you want to call. Filename must have a .BAT extension. The latter sentence is not true in DOS 5.0. CALL works equally well whether "filename" is a .BAT, .COM, or .EXE file, or even internal command the following all work just fine: call dir call mem call tree call echo Phhhhhhht! Gary Smith Is it safe to use CALL filename even if filename is a .COM or an .EXE file as opposed to a .BAT file? I know it works; I'm just curious if it's not good to do so. George Steinmetz The MS-DOS dox are silent on the issue, but I have done it on a number of systems in just the situation you describe, where I didn't know in advance if a .COM, .EXE, or .BAT file would be called. I have *never* had a problem with it, and it doesn't seem to use any more memory either. Gary Novosielski As far as DOSKEY macros go, I don't think you can run them from batch files so they're no problem. Erik Ratcliffe I can confirm that, Erik. The DOSKEY command can be used within a batch file to create a macro, but you cannot run a macro from a batch file. John Evans I beg to differ, since no-one else appears to have jumped in on this one. Try the following: @echo off doskey fred=dir/w echo fred | call Rudy Lacchin The online Help states quite clearly that it is _not_ possible to run a macro from within a batchfile. OTOH, "echo", "|" and "call" are all documented, so one could argue that it falls under the category "tips and tricks". What puzzles me is that "call {macroname}" doesn't work but "echo {macroname} | call" does?!? John Evans This puzzled me at first but isn't this what is happening; when you put CALL FRED, then CALL is looking for an executable (com,bat,exe file) to call, as it doesn't exist it fails (Bad Command...(?)), but ECHO FRED|CALL, actually sends the output of FRED which is dir/w to call and so as dir/w is a valid call statement it succeeds. To prove this I made batch files with the following commands, which gave the associated results: doskey fred=dir/w Succeeded and gave a dir/w listing. echo fred|call doskey fred=dir/w Failed with a "Bad command or filename" call fred error. call dir/w succeeded and gave a dir/w listing So I think my reasoning is correct. First time for everything. Terry Kreft =============================================================================== 3) CHKDSK EDITOR'S NOTE: Technically the following information is NOT a MUF, but is included here due to the fact that it may help save someone a lot of grief! Similar to advising others not to use delayed cache writes and DOS 6.0's DoubleSpace. CHKDSK Can you tell me the _date_ of the BAD CHKDSK? I live in fear of it as I mainly work on other peoples computers an I have no way of telling if I will destroy their HD with a simple chkdsk command! Wallace Mcgee The only problem with CHKDSK is with large partitions where DOS uses a 256-sector FAT. Specifically with partition sizes in the ranges of: 127MB-129MB 254MB-258MB 508MB-516MB 1018MB-1030MB 2035MB-2061MB The date of the CHKDSK that has that problem is 04/09/91. The replacement being dated 11/11/91. UNDELETE has the same problem for the same reason. Bottom line is - if you don't have partitions in these size ranges - you don't have a problem. The corrected versions can be had by downloading from the MS BBS. Probably also available off of CompuServ. The file to look for is: PD0646.EXE. The phone number for the MS BBS is (206) 936-6735. Hope that helps you and others with the same question. Steve Osterday From Microsoft: INTRODUCTION The Microsoft MS-DOS CHKDSK and UNDELETE commands dated 04/09/91, which are included in the Microsoft MS-DOS 5 Upgrade, do not work correctly on logical drives that require 256 sectors to store each copy of the file allocation table (FAT). If any of the partitions on your hard disk drive are within the ranges listed in the following section and you do not have version 5.0a of the Microsoft MS-DOS 5 Upgrade, which includes CHKDSK.EXE and UNDELETE.EXE files dated 11/11/91, install the updated CHKDSK.EXE and UNDELETE.EXE files included with this application note. If your FAT occupies 256 sectors, using the CHKDSK.EXE file dated 04/09/91 with the /f parameter ("chkdsk /f" [without the quotation marks]) can result in data loss. Using the UNDELETE.EXE file dated 04/09/91 can lead to unpredictable results. DETERMINING IF YOU NEED TO INSTALL THE UPDATED FILES Drives require a 256-sector FAT if they have partitions within the size ranges listed below. Because the potential problems are serious, these ranges include a margin of safety. 127 MB-129 MB 254 MB-258 MB 508 MB-516 MB 1018 MB-1030 MB 2035 MB-2061 MB You can use the Fdisk program to determine if you have a 256-sector FAT with the following procedure: 1. At the MS-DOS command prompt, type the following and press the ENTER key: fdisk 2. Press 4 on the keyboard to select the Display Partition Information option and press ENTER. 3. The primary partition size is listed under the Mbytes heading. If the size falls within any of the ranges specified above, install the updated CHKDSK.EXE and UNDELETE.EXE files on the enclosed PD0646 disk. 4. If you have an extended partition, press the ENTER key to view those partition sizes. If any of the extended partition sizes listed under the Mbytes heading fall within the ranges specified above, install the CHKDSK.EXE and UNDELETE.EXE files on the enclosed PD0646 disk. 5. Press the ESC key twice to exit to the MS-DOS command prompt. Posted by: Vernon Frazee In just about all versions of Dos (At LEAST Msdos though I've been told others have the same problem), You cannot normally use a hard drive which has more than 1024 Cylinders. It isn't a limitation of my BIOS since I can use these Cylinders in the Linux O/S with ease. Dos Fdisk will only recognize up to 128 megs of the 152 meg priam MFM drive I have. Most IDE drives can have more than 1024 but they trick dos and the Bios into thinking they only have 1024. I was using a program called "Disk Manager V5" (nothing to do with Norton Utilities) which loaded a driver into memory to access the rest of the cylinders and do a "Fake" Fdisk. What I mean by that is it kept the info on the partition in a file for it's own use. It didn't actually access the partition on the Priam. Linux does but the MsDos "FORMAT" won't even deal with a partition that goes past the 1024 cylinders (Even if it IS there). Microsoft and IBM won't acknowledge it's existence and I may want to use this Hard Drive in Dos again sometime. I'm currently using Dos 6.20 (probably the most undocumented Dos of them all I would imagine.) Sean Kearney =============================================================================== 4) CHOICE I blundered onto an interesting choice.com feature: CHOICE /C:XM*; /N /T:2,5 if errorlevel=4 goto help if errorlevel=3 goto end ...etc The "*" is the escape key, and the ";" is F1 etc. Robert Lindsay I can't reproduce the "feature". Particularly, the * does not recognize the Esc key. All I get is a beep. I'm using Choice.com from the DOS6SUPP archive (though under DOS 5.0). Later: It occurred to me I hadn't tried an actual Esc character (ascii 27, small left-pointing arrow). I did now, and it *does* work. You have to use an editor that allows you to enter an Esc character (most do, I think). I couldn't get the ";" to be recognized as a function key though. Gerry Pareja The ";" is just part of the "ASCII code" for F1. F1 actually gives an ASCII 000, to mark an extended key, and then the semi-colon. CHOICE will beep at the 000, and then accept the semi-colon. Scott Wunsch Since I am running DOS6, I shelled out when I read your msg and created TEST.BAT, whose command line is exactly as: CHOICE /C:XM*; /N /T:2,5 with the insertion of the little ^[ symbol (lp arrow) for the * and F1 for the ;. When I executed TEST I got the following feedback: C:\PP\BW>CHOICE /C:XMF1 /N /T:2,5 CHOICE: Timeout default not in specified (or default) choices. NOTE: Even tho the ^[ symbol does not show up, it was reconfirmed to be in TEST.BAT. Bat Lang Here's a layman's attempt to throw some light on the matter: The above syntax will produce an error because of the "/T:2,5", but that's beside the point. My understanding of the above is that CHOICE interprets the keyboard scan code as an ASCII code. In other words, if the scan code for a particular key (or any part of it) corresponds to an ASCII character which can be used as an argument to the /C switch, then that key may be used with CHOICE. The second part of the scan code for F1 for instance is 59, which is the ASCII code for a semicolon. Therefore "CHOICE /C:ABC;" will accept either the semicolon key or the F1 key. If you press F1 a beep will sound because of the first part of the scan code, but the second part (59) is interpreted as a semicolon and is accepted. Another example: The code for "page down" is 81 which is the same as a "Q", so if q is one of the arguments to the /C switch, pressing "page down" will work as well (but with a preceding beep). The ESC character (scan code 01) doesn't fit in with the above theory, but works fine if represented by an ASCII 27 (left pointing arrow). Some ASCII equivalents to scan codes cannot be used with CHOICE. F2 and F4 for instance, both require a redirection symbol, which obviously can't work. Another drawback is that if (like mine) the f-keys have been allocated functions under DOS (via PROMPT), you get as many beeps as there are characters allocated (until one of the characters happens to coincide with one that CHOICE is expecting). My F12 key, for instance, gives me 10 seconds of beeps. :-) Tested with MS-DOS 6.00. John Evans F1 is an extended key. It doesn't actually have an ASCII code, as such, so the BIOS gives it an "ASCII code" of 0, or a null. After it sends the null, it sends the scan code of the key, so that programs can figure out which extended key it was. The scan code for F1 is 59 (the ASCII code for a semi-colon). So you enter the command: CHOICE /N/C:; CHOICE calls the BIOS and asks it to get it a key. You hit F1. The BIOS sends the null (ASCII 0) to mark an extended key. CHOICE doesn't like this and beeps. It goes back to the BIOS and asks for another key. Now the BIOS hasn't finished with the F1. It sends the semi-colon to tell CHOICE which extended key it was. Well, CHOICE isn't smart enough to figure out that ASCII 0 means an extended key, so it had just ignored it. Now it sees this semi-colon, and decides it must be a perfectly valid key. The function keys' "scan codes" are as follows: F1: ; [059] F2: < [060] F3: = [061] F4: > [062] F5: ? [063] F6: @ [064] F7: A [065] F8: B [066] F9: C [067] F10: D [068] F11: … [133] F12: † [134] Obviously, you're not going to be able to use F2 or F4 in a batch file :(. Scott Wunsch =============================================================================== 5) COM or EXE Also, have you noticed that 4DOS.COM (when viewed with LIST) begins with the letters "MZ"? Isn't that the mark of a .EXE file? Very interesting... Thomas Smith It sure is, and that's an example of something else that may be a MUF. DOS doesn't care whether the extension on an executable file is .COM or .EXE. It looks at the beginning of the file and does the right thing according to what it finds. Gary Smith The identifier of an EXE file does not have to be MZ, ZM will execute just fine too! (Other identifiers will not work however). Jonas Oberg =============================================================================== 6) COMMAND, SHELL, and SYS SHELL=C:\COMMAND.COM /E:1024 /F /P COMMAND /F The /F in your Config.sys SHELL= statement is another undocumented feature. It forces a "Fail" response to the "Abort, Retry, Fail" prompt issued by the DOS critical error handler. Dennis McCunney What is the /F for in your SHELL statement? My DOS manuals make no mention of an /F switch. It does mention that command line parameters accepted by the command processor can be passed via the shell statement. However, my DOS manuals make no mention of such a switch for COMMAND.COM either. Was that a typo? Gary Cooper Nope, It's another undocumented feature. What I believe it is supposed to do is force a "Fail" response to the "Abort, Retry, Fail" message issued by the DOS critical error handler. I run 4DOS, so I've had no occasion to actually test it. Dennis Mccunney The /F switch on the SHELL command in CONFIG.SYS will not work in a DESQview environment. The only thing I have found that will is a program called FATAL.COM. Bruce Bowman Makes all those annoying "Abort, Retry, Ignore, Fail?" disk error messages default to "Fail". Erik Ratcliffe I thought this was well established as being available from v3.3 I certainly use it with MSDOSv5.0a and its been mentioned since my early days in the echo back in Feb'93. E.G. @echo off if %1.==. goto syntax echo %comspec% /f /c copyprn$.bat>temp$$$$.bat echo copy %1 prn: >copyprn$.bat call temp$$$$.bat if exist ???????$.bat del ???????$.bat >nul goto end :syntax echo Usage: %0 [filename.ext] echo Prints [filename.ext] if printer is ready. echo If not terminates. :end I've posted this example usage myself - its handy if the printer is the other side of a wall and you can't see if its ready. Mark J. Allen Yes, MS-DOS COMMAND.COM's "/F" parameter (default to Fail when it cannot read a disk) works on all versions since MS-DOS v3.30. Vernon Frazee It certainly works with 3.3 Tom Coleman I've used it (successfully) with M$ Dos 5.0, 6.0, 6.2. I will retest, as well include some other versions of it. I figured that someone had re-covered it by now, however I will send you some NFO on it. Steve Adams I first used it with 5.0.....and have used it with 6.0 and 6.2. John Mudge I have just tested "command /f" in MSDOS 3.21 by booting from my original (1988) floppy. It worked!! I booted from A: drive, typed "ver" to confirm the version in use was MSDOS 3.21, typed command /f, switched default drive to C:, then opened the floppy door on A: and typed "dir A:". After a few seconds the Not ready reading Drive A: message appeared, about 5 seconds later I was returned to the "C:" prompt. Pete Smith I normally run DOS 3.31 on an old XT, but in Swedish translation. It didn't work exactly as in your experiment. I wonder, if that is because the alternatives are not Abort, Retry, Fail, but Avbryt, F”rs”k igen, G† vidare. Ie the "F" option is the "retry" option. Ragnar St¸Hle Since the infamous DOS error message "Abort, Retry, Ignore?" didn't become a more chilling "Abort, Retry, Ignore, Fail?" until DOS 3.3, COMMAND.COM's undocumented "/F" parameter (default to Fail) probably wouldn't have been discovered, if it existed, in earlier releases. Vernon Frazee Microsoft(R) MS-DOS(R) Version 3.20 (C)Copyright Microsoft Corp 1981-1986 A>c:\u2\ssxtra 5000 /q A>command /f Microsoft(R) MS-DOS(R) Version 3.20 (C)Copyright Microsoft Corp 1981-1986 A>dir b: Not ready error reading drive B Abort, Retry, Ignore? Volume in drive B has no label Not ready error reading drive B Abort, Retry, Ignore? Not ready error reading drive B Abort, Retry, Ignore? Invalid drive specification A> My first computer was a Commodore XT clone with MS-DOS 3.2. I was using the /f switch then, and remember experiencing the same 30 second delay. I just booted up my 386 with v3.2 and tried the same thing. The delay was less than a second. Evidently, the delay factor depends more on hardware (and maybe BIOS) than the DOS version. David Adamson I just shelled to invoke a COMMAND from a 2.0 floppy and it crashed my server! Tue 5-13-2* 8:16:08*A:\>c:\u2\ssxtra 5000 *NOT* residentśstatus=ONśmode=ANYśtimer=3śINSTALLEDś (5000) buffer size requested, Available: (5014) Tue 5-13-2* 8:16:15*A:\>command /f Command v. 2.11 Tue 5-13-2* 8:16:27*A:\>dir b: Not ready error reading drive B Abort, Retry, Ignore? f Abort, Retry, Ignore? f Abort, Retry, Ignore? (Captured/written-to-disk _at_ the Crit-Err prompt via SSXTRA ((fwiw I also command /F,a,A,i, and I with identical results)) (((All DOS's "R"etry minimum 3 times before -> crit-err))) then.... Microsoft(R) MS-DOS(R) Version 3.20 (C)Copyright Microsoft Corp 1981-1986 A>c:\u2\ssxtra 5000 /q A>command /f Microsoft(R) MS-DOS(R) Version 3.20 (C)Copyright Microsoft Corp 1981-1986 A>dir b: Not ready error reading drive B Abort, Retry, Ignore? Volume in drive B has no label Not ready error reading drive B Abort, Retry, Ignore? Not ready error reading drive B Abort, Retry, Ignore? Invalid drive specification A> w/ No intervention on my part at all, although it took over 30" to get back to the prompt. So "/f" processing *is* present, if very shoddily implemented, in MS's 3.2. (which is also pretty darn buggy otherwise) Don Hoffman YES "command /f" does work on MS-DOS 3.21. Pete Smith COMMAND /P Docs say that this doesn't allow you to exit back to the previous shell (ie /Permanent), but /P also forces \autoexec.bat to be run on secondary shells. COMMAND /D (When used with a primary shell, or secondary with /P) prevents execution of \autoexec.bat Mitch Ames I just checked, and these also both apply to DOS 5.00 Mitch Ames COMMAND /E: ...remember the constantly returning thread of getting secondary shells' environments greater than 256 bytes? Well I had cause to mess around on someone's machine and needed a larger secondary shell from a pgm that didn't allow shell definition when it dawned on me that you can just modify the COMSPEC variable to include the trailing /e:#### and as most well behaved pgms use the comspec variable this works wonderfully! Mark J. Allen I've never tried that. I thought I read someone here did that and it wasn't accepted by the program, but it sounds like an excellent solution. Rob Flor Well, I had the same idea some time ago, but I can't report the same success as you had. :-( I experienced the whole range of inexplicable errors, crashed programs, system hangups, etc. Seeing as /E is a valid parameter for COMMAND.COM, It must be something to do with the (faulty?) way certain programmes handle the comspec variable. John Evans I tried it for a day or so the last time the "how to increase the environment" went round. May just be my choices in s/w, but I didn't find a single pgm that was able to shell successfully via the adulterated comspec. Don Hoffman Or you could do: COMMAND.COM /E:5000 /C C:\YOURAPP.BAT Single line, decrease/increase the environment as needed. No SET's needed. And as far as I can tell, it works just great under DOS5.0, when running DESQview, I run multiple windows, and am running a VBBS multinode system. When I shell out to DOS(in that window), the batch files I have running will not function if I DON'T change the /E: size, and in most cases lock up the system. However, I have never had a problem since using the above statement. What it is doing I can not say, but it sure works here! Tony Talarigo SHELL=COMMAND.COM /NUL Adding a "/NUL" to the SHELL= statement in CONFIG.SYS will remove the possibility of a user being able to use [Ctrl-C]. Example: SHELL=C:\DOS\COMMAND.COM C:\DOS /E:1024 /NUL /P Vernon Frazee SHELL=C:\COMMAND.COM C:\ /p ~~~ The second parameter tells the OS where to find the command processor when the transient code is overwritten. In addition, the inclusion of this parameter in the SHELL statement will automatically put the COMSPEC environment variable in the environment for you. Robert Clark The word on my block is that the second parameter is simply wasted typing (read: redundant), UNLESS the CP is not in the root (as it is above). Accordingly my shell line has never included it, yet when I enter SET at DOS, I always see as the first environment variable, the COMSPEC line. Could this be a MUF? Just a hold over from some earlier versions of DOS? I am using 6.2, but cannot remember using that second parameter, since the word went around {^; (I may have read that from either Dan Gookin or DOS Power Tools). Bat Lang It was introduced with DOS 4, which needed SHARE to support large media (40meg HD). If SHARE wasn't loaded in config.sys, DOS used the second parameter to find SHARE.EXE, not COMMAND.COM. If command.com is in the root, you don't even need a shell or explicit comspec statement. Rob Flor NO COMMAND.COM IN ROOT DIRECTORY MS-DOS doesn't use a specific location any more (for system files). You can move'm around all you want. At least since DOS 5. Dos 5+ system files aren't position sensitive. Just replace dos 5 with dos 6 including command.com and system files, then reboot the machine. Try it yourself. Format a floppy with dos 5, copy new system/command.com to it, and reboot. Rob Flor In the absence of a SHELL statement, MS-DOS v6.x looks for the CP (command processor) first in the \DOS directory, then in the root, then in \MSDOS. The COMSPEC evar will then be set to wherever the CP was found. Robert Clark The three subdirectories, "\", "\DOS", and "\MSDOS" can be seen inside DOS's hidden "IO.SYS" file and, DOS automatically sets the COMSPEC environment variable to point to the location of the COMMAND.COM it booted with. Vernon Frazee Is this search pattern documented anywhere that you have seen? Gary Cooper Not officially, at least not that I'm aware of. Someone over in the RIME DOS conference mentioned this over a year ago, and a little experimentation at the office showed that the search pattern worked as advertised. I'm just showing my (operating system) age. In the absence of a SHELL statement, MS-DOS v6.x looks for the CP (command processor) first in the \DOS directory, then in the root, then in \MSDOS. The COMSPEC evar will then be set to wherever the CP was found. Previous versions would choke and die horribly if the CP weren't in the root and there was no SHELL directive. Also, the COMSPEC would only be created if the second parameter in the statement SHELL=\foo\path\foo.bar \foo\path\... was present. ^^^^^^^^^^ In the absence of a SHELL statement, MS-DOS v6.x looks for the CP first in the \DOS directory, then in the root, then in \MSDOS. The COMSPEC evar will then be set to wherever the CP was found. Robert Clark DR-DOS 6 doesn't care where it's corresponding files (IBMBIOS.COM, IBMDOS.COM) are physically located, so long as they are in the root directory. In fact, I have sometimes run ATTRIB -RH on them so that a HD defrag program would move them. Tom Schluter The same is true of MS-DOS, versions 5.0 and later. Gary Smith Yes, happens here too (DOS 5.00). Even more annoying is that the expen$ive Norton Utilities will get fooled too. You can't "Make a diskette bootable" unless COMMAND.COM is on the root of C:\ regardless of the value of COMSPEC. Gerry Pareja ? ... working here: a) Running MSDOS v5.00 revA b) SHELL=C:\DOS\COMMAND.COM c) COMSPEC=C:\DOS\COMMAND.COM d) and _no_ COMMAND.COM in the root dir A subsequent: FORMAT A: /Q /U /S /V:"" /F:1.2 command produces a bootable 1.2meg floppy (with IO.SYS, MSDOS.SYS, and COMMAND.COM). Vernon Frazee Yes the above works, what doesn't work is: SYS C: A: You get the message "Could not copy COMMAND.COM onto target disk", you can of course copy COMMAND.COM to the target disk manually. The same is true in Dos 6.00 and 6.20, except DBLSPACE.BIN also gets copied over as a system file. So FORMAT is able to use comspec to find COMMAND.COM, but the SYS command is not. Terry Kreft The only problem seems to me that doing SYS A: will come up with the message "Could not copy COMMAND.COM onto target disk" (and what you have to do then is obvious). John Gray My SHELL command has always pointed to my MSDOS directory, but I've always had a copy of COMMAND.COM in the root (I think INSTALL puts it there). I've just deleted it on two machines (one with 6.00 German and one with 6.20 English) and, sure enough, the SYS command couldn't find it on either machine. Up until now I've always believed my big thick DOS 6.00 bible, which clearly states that the SYS command will search for COMMAND.COM in the path specified by the COMSPEC variable... John Evans I'm using NDOS and I don't have COMMAND.COM (or NDOS.COM for that matter) in the root directory and I just formatted a diskette to be bootable using SFORMAT. Scott Paterson C:\dir a: /a +- Now what's on A: | Volume in drive A has no label | Volume Serial Number is 4029-12F7 | Directory of A:\ | | DBLSPACE BIN 64,246 09-30-93 6:20a +- No COMMAND.COM! IO SYS 40,566 09-30-93 6:20a | Also I don't have MSDOS SYS 38,138 09-30-93 6:20a | DBLSPACE.BIN in my 3 file(s) 142,950 bytes | root. So it managed 1,313,792 bytes free | to find that. | C:\ +- Done Note this is with MSDos 6.20! Wonder why SYS doesn't work "properly" (i.e. doesn't use COMSPEC to find COMMAND.COM) if they fixed it for the version your using on that set-up. Aha, I got my MSDos 5.00 disk working and SYSed my HD to 5.00, deleted COMMAND.COM from root and SYSed a floppy (using MSDos 5.00 SYS.COM) and it copied COMMAND.COM over, so for some reason they've taken the facility (to use COMSPEC to find COMMAND.COM) out! Terry Kreft =============================================================================== 7) COPY Using: COPY is the same thing as: FOR %%1 IN () DO COPY +%%1 such as: COPY *.TXT ALLTEXT.DOC is the same as: FOR %%1 IN <*.TXT> DO COPY ALLTEXT.DOC+%%1 ALLTEXT.DOC I used this one to combine all the MUF files to one file by saying copy *.txt muftext.doc any wildcard specs and exp. filename will work just fine... Mike Anderson Try: COPY FIRST+SECOND FIRST Whatever happens, it is a DOS requirement that you have to create a completely new file, with both sets of records in it -- this is just how ordinary DOS files work, I'm afraid, so you're stuck with it. John Gray Unless you do this one: TYPE SECOND >> FIRST However, if FIRST has an EOF mark, it will probably not be removed with old M$-DOS versions (my M$-DOS 5.0 works fine though). Horst Schaeffer Well, would you believe it! You seem to have found an exception to my 'rule'! Well done... John Gray You can do: COPY FIRST+SECOND with the same results. (The SECOND file concatenates to the FIRST). Vernon Frazee This is true -- yet another undocumented feature? John Gray Command.Com won't copy a zero-length file; 4DOS will - thus breaking all those bat files which use this "feature". Mitch Ames Actually, I thought this was a problem in some of the newer (5.0+?) versions of DOS. Scott Wunsch I believe this "feature" has been around since at least v3.30, and it is documented in v5.0 (p391 of the manual). I just checked and v3.30 of command.com can't copy 0 length files either, but it is _not_ documented in the 3.30 (MS-DOS) manual. Mitch Ames (EDITOR'S NOTE: See the DIR and DELIMITING CHARACTERS sections as well for additional information on the use of . , .. \ etc. as below) I acknowledge that some of the information presented in these sections may be documented, although obscure features. The reason that this information continues to be seen in the MUF list is because I believe that the ability to use the period immediately after the copy command IE: COPY. is not documented. What is documented is the fact that "." and ".." can be used to represent the current and parent directories respectively, and these will work with many applications which can handle directory names as arguments. In this case the "." could also be viewed as a replacement for "*.*" COPY. A: The use of a decimal point IMMEDIATELY after some DOS statements, will replace *.* EXAMPLES: DEL. (erase all files in current directory) COPY. A: (copy all files in current directory to A:) There may be more statements with which it works, but I haven't tried them yet. Willem van den Broek "." means the current directory, and Command.com will assume that \directory implies \directory\*.* for most commands where a filename(s) should be specified, eg: DIR \ is the same as DIR \*.* COPY \FRED is the same as COPY \FRED\*.* COPY. A:\ is the same as COPY .\*.* A:\ which is the same as COPY *.* A:\ DEL. is the same as DEL .\*.* which is the same as DEL *.* Mitch Ames =============================================================================== 8) CTTY EDITOR'S NOTE: The following section consists of extracts from messages which have answered the question: "How do I stop the program output (during the loading of CONFIG.SYS) from being echo'd to my screen". Many have suggested that users redirect the output to the NUL device, however, this technique has been found to cause errors when the program being loaded is a TSR (Terminate and Stay Resident). The errors are due to the fact that the TSR does not release the file handle which is used in the redirection process. The reason I started using ctty was because of a message in a echo which I now forget, maybe debug. Some guy was having a problem to which he got the response that too many program > nul used up "handles". Dan Dunfee There's a thread going on here now about redirection not releasing file handles when you re-direct output from a TSR. I don't think its a problem otherwise, didn't know it was a problem with TSR's. Jack Stein FYI, the same thing happens (trapped file handles) when you CTTY>NUL and load a TSR. Gary Cooper That would be the heading in my DOS manual (CTTY) where I would "expect" to find warnings about redirecting TSRs... but mine doesn't even acknowledge that "nul" _is_ a valid value for CTTY (although I've been using it to hide stuff since 2.0, and my 670 page manual _does_ list "prn, lpt1-3, con, aux, and com1-4" as valid devices to ctty to.) AH HA! Now it *is* a MUF! "CTTY NUL" is *UN*documented and WILL WASTE a file handle if used in conjunction with loading a TSR. The same will happen if you "redirect" a TSR to nul. Don Hoffman In the FWIW department I had to test/verify the CTTY thing for myself (just now,) and I found something slightly interesting in that the 'releaser' pgm: FILES - (c) 1993 Holger Daehre 2:248/317.88 which BERND HOHMANN kindly posted here was _not_ able to recover all the handles I trashed via: .bat file: ctty nul fmark %tmp%test.mrk eatmem 1 eatmem 1 eatmem 1 eatmem 1 ctty con It initially showed 2 handles lost and unrecoverable; When I RELEASEd /K(ept mark) it still showed 2 gone/unrecoverable... but after a second RELEASE (of test.mrk too) it reported 1 file handle reclaimed, and one still lost. A second run w/ the EATMEMs commented-out lost me another handle which couldn't be recovered regardless of RELEASEs done. (I even released all the way back to my '00' mark, which kills everything except my command processor... 2 extra handles still reported as in-use / unrecoverable): Number of used handles before cleaning : 006 Number of used handles after cleaning : 006 (should be 4 at this point, including the redirection for capture, but note I do _not_ have any alternate technique to verify / crosscheck these numbers with!) I expect 'your milage may vary'... maybe something about my (ancient 8088 semi-compat) hardware, and/or software platform (IBM 2.0.11 + MS 5.0 + 4DOS)... or maybe even pgm bug. (Those results don't make a lot of sense to me... but it's hardly something I should be doing in the first place ;-)) Don Hoffman EDITOR'S NOTE: In response to a question asking why: MD C:TEMP > NUL did not work as expected... If C:\TEMP already exists, MS-DOS 6.2 will STILL REPORT that fact, even with the " > NUL" output redirect. If the original poster needed a completely silent process, this won't quite do it. Steve Burton True, however CTTY NUL before the md command, and CTTY CON after still works, eg: ctty nul md c:\temp copy a:\*.* c:\temp ctty con Unfortunately, CTTY >NUL no longer works, at least in Dos 6.2 Dale Woloshin =============================================================================== 9) DELIMITING CHARACTERS Prior to DOS 5.0, there was an undocumented DOS function that would allow you to set the DOS option delimiting character to something else, like -. Once you did this, you could use either \ *or* / in PATH specs. DOS 5.0 removed the function to *set* the option delimiter, but *retained* the one to query what it currently is! (Don't ask me, ask M'Soft...) Fortunately, the MKS Toolkit still works with no apparent glitches. I believe in pre-DOS 3.X versions that there was a parm you could provide in CONFIG.SYS to do this, but have no further details. Just remember: "undocumented" is a synonym for "unsupported, and not guaranteed to be there next release", which is what happened in the case I mentioned above. Dennis Mccunney Another good thing is you can travel from directories to directories without typing "CD". Just type the directory name followed by a backslash '\'. Example: To go from C:\BATCH to C:\WP51, you type "\wp51\". That's it! fast and easy. Marc Y. Paulin This is a 4DOS/NDOS feature; it is not available under COMMAND.COM. Scott Wunsch If you are in the following directory : \WORD\FILES\LETTERS\APRIL And wanted to go to the directory \WORD\FILES, you'd normally type two lines : CD \ CD WORD\FILES Or even the single line "CD \WORD\FILES" to combine the two commands into one. There is a shorter way, simply type the following : CD ..\.. You're there! Andrew Barnhardt I just found out that using the command DELTREE . cause the deletion of all directories with verification, ie 'do you want to delete the directory somedir and all subdirectories and files?'. If you've got 6 directories in the directory your in you get prompted for each one. Kirt Thomas While the on-line help does not specifically mention using the dot "." character, it does have a section stating that you can use wildcards. I consider the dot to be a wildcard. It says that if you use a wildcard, any matching files and directories will be deleted. Michael Clays EDITOR'S NOTE: For additional information regarding the use of "." as a wildcard see the DIR section. Have you tried the subject line? i.e. DELTREE /Y C:\TEMP\ (note the trailing backslash) With MSDOS 6.22 it will delete all files in, and all subdirectories below, but will NOT delete \TEMP itself! Michael Marquart I get two empty directories in each directory, too. (called"." and "..") Maybe because mine are 4096-bytes? Bob Browar Every directory you create off of the root directory will contain a "." (single dot) and a ".." (double dots). The single-dot is an abbreviation for the current directory and the double-dot is an abbreviation for the next directory up (parent) The single-dot is really pretty useless as far as when using it with one of the directory commands: MD (make directory), CD (change directory), or RD (remove directory). But, it can be used to do something like: a) Copy everything in your current directory to A:\ copy . a:\ b) Create a zero-length file: cd.>x (file "x" will be a zero-byte file) d) Even handier but possibly disastrous, the following command will not only delete all the directories of, but of all the files (even the ones with the Hidden, System, and Read-Only attributes assigned) in and below, your current directory: deltree /y . For example, if you had the directory structure: A:. \---TEST +---1 +---2 +---3 +---4 \---5 had files (even hidden) in any or all of the directories, and you were in the root directory of drive A:, the command: deltree /y . would delete _everything_ below the "." (current) directory. The double-dot ("..") directory entry comes in handy when you want to change to a sister directory. For example, take the same directory structure: A:. \---TEST +---1 +---2 +---3 +---4 \---5 Then let's say you're in directory "A:\TEST\3" and want to change to "A:\TEST\5". Instead of typing: cd\test cd 5 or: cd\test\5 you could just type: cd ..\5 (Remember, the ".." stands for the next directory up (the parent)). Let's say you were in "A:\TEST" and wanted to copy everything in it to the root directory: copy . .. (In other words, copy "current-directory" to "parent-directory"). If you wanted to copy everything from the root to where you were: copy .. This is but a _small_ example of how the single- and double-dot directory entries can come in handy with a variety of commands. Vernon Frazee =============================================================================== 10) DEVICEHIGH This line in CONFIG.SYS will, according to MS-DOS 6.22 help, prompt the user about loading the device with the classic [Y,N] DEVICEHIGH? /L:1,9072 =C:\DOS\ANSI.SYS And so it did for me until I ventured into multiconfig to accommodate some EMS demanding proggies. It appears that once the [MENU] is added to CONFIG.SYS this is no longer an option. Not a major hassle, as a submenu can be used as a work around, but I was unable to locate any mention of this drawback in the HELP. Peter Lovell =============================================================================== 11) DIR DIR (, . ...) DIR, Using a comma IMMEDIATELY after DIR, shows ALL files, including the HIDDEN ones. EXAMPLE: DIR, Willem van den Broek EDITOR'S NOTE: As you will read below, there are mixed reports as to whether this MUF will work the same with all versions of DOS. Warning: Your "mileage may vary". Much of what is reported in this section might also have been covered in the Delimiting Characters section. Just tried it here, booting off of an original MS-DOS 3.30 diskette, and what Mr. Broek stated is true. Vernon Frazee Going back as far as DOS 3.3, it is possible to find hidden files, and hidden directories for that matter by using the following: DIR, It seems a bit easier than testing for attributes. It simply show all files in the required directory Greg Miskelly This appears only to work with version 5. I tried it with 3.30, and it didn't display either IO.SYS, MSDOS.SYS (both with S, H and R attribs) or a test file with A and H attribs. With version 5 it displayed the test file with H and A, but would not display IO.SYS or MSDOS.SYS with S, H and R. This doesn't surprise me actually, since S alone (without H) will prevent inclusion of a file in a normal DIR. I didn't try version 4. Mitch Ames I can confirm that the DIR, does NOT work with MS-DOS 3.2, 3.3, and 4.01, nor with Compaq DOS 3.31, DR-DOS 6.0, or Novell DOS 7. Works here with MS-DOS 5.0, MS-DOS 6.0, and MS-DOS 6.22. Ron Warder It also works as DIR , (with an intervening blank). John Gray MS-DOS Version 5.00 C:\ >dir , Volume in drive C has no label Volume Serial Number is 1221-0000 Directory of C:\ IO.SYS MSDOS.SYS [BATCH] * * * WINA20.386 36 file(s) 508790 bytes 35735552 bytes free MS-DOS Version 5.00 C:\ >attrib io.sys SH C:\IO.SYS As you can see, this system's using MS-DOS 5.0, IO.SYS is System and Hidden, and "Dir ," displayed both it and MSDOS.SYS. Bruce Wilson It works here with PC-DOS 6.1 Rodney Foremski I dug out my old disks and rebooted to try each version with the following results: MS-DOS Version 3.21 12-03-87 3:21a IBM Personal Computer DOS Version 3.30 3-17-87 12:00p dir, - does not show hidden files in either version, - the original manual I received with V3.21 only lists the +/- A and +/- R options for the ATTRIB command, no mention of the ability to set or modify the System or Hidden attributes. - any attempt to set or unset the System or Hidden attributes on a file using ATTRIB under these DOS versions results in a "Syntax error" message. MS-DOS Version 5.00 04-09-91 5:00a dir, - displays all files in the current directory regardless of attributes set (Archive,System,Hidden,Read only) - online help and manuals fully document the ATTRIB command's ability to set/unset all attributes. Those are the only DOS versions I have handy, hope this helps. Pete Smith Interesting: it (DIR,) does for me (display DOS5 IO.SYS and MSDOS.SYS): However, 4DOS does not do it: Dennis Mccunney It was pointed out in the 4DOS echo, and there were people who said it didn't work for them. But, on my machine running straight dos6, it works! DIR, (dir comma) in my C:\ shows all files including hidden and system. Bill George EDITOR'S NOTE: In response to the following comment: If you include the /b switch, you'll get the complete pathname for each file. Also if you use the forward slash you'll get all the dll files on the current drive. dir/s/b \*.dll|sort>dll.txt Jeff Martin EDITOR'S NOTE: Jeff receive the response: You will, UNLESS you happen to HIDE a directory or two (or three)! This command will NOT report ANY files that are inside a hidden directory tree. I played with this a bit, but didn't find a way to include hidden dirs and/or hidden files with a "simple" command. Gary Smith There is an undocumented variation. dir, that will include system and hidden directories/files. The comma needs to be right after the r. Roger Scudder No, actually it doesn't...try "DIR ," or even "DIR/P ," and it still works, *but* you canNOT (as far as I can tell) use the "comma MUF" when you SPECIFY a target, ie the *.DLL in the original example. dir/s/b \*.dll|sort>dll.txt Greg Smith DIR.. With DOS 6.0 you can get a directory of -all- files (hidden, system, etc.) with this command. It was in a PC/Mag. or PC/Comp. issue not too long ago. Andrew Barnhardt DIR... Have you noticed also how DIR ... only displays directories, not files? Gary Marden That's pretty slick. I tried DIR.. and got the parent directory. DIR... got the current directory subdirs only. Bill George Works for any level of directories. ".." will go to the previous directory as with pure DOS, "..." will go to the directory before the previous and so on. Ng Cheng Kiang In DOS 5.0, it displays files and directories which have no extension. Larry Kessler Here's another gem discovered here for DIR, try DIR... shows only subdirs. Richard Gray In DOS 5.0 it displays directories and files with no extensions. I tried "DIR ...", "DIR...", and "DIR ....". They all behave the same way. Gary Smith With DOS 5.0 and NDOS 6.0, DIR... gives me a list of subdirectories off of the root and a list of all files in the root directory, regardless of the file extension. It will yield this result regardless of what directory or subdirectory I am in at the time the command is issued. Gary Cooper This is, I believe, a result of another little feature (MUF?), that allows DIR to accept an extension like this: "DIR .BAT". This would act like "DIR *.BAT". Because DOS automatically trims off useless characters, it trims the "..." down to a ".", but doesn't process it as meaning the current directory because it is already past that part of its processing. This is because 4DOS/NDOS can handle ... as the "parent of the parent directory". So if you were more than three directories deep, then DIR... would no longer give you the root. Scott Wunsch COMMAND.COM generally seems to ignore excess characters. Try copying something the AIRPLANES.PLAN, for example, and see what happens. Gary Smith While I was playing around with "dir ..." and trying to see how it parses to showing all extensionless entities in the current directory, I noticed that DIR doesn't care if a specified directory structure exists or not, as long as the overall structure points back to something that does exist, i.e. dir \thisdirdoesnotexist\.. will ignore the garbage and show the root directory. If c:\bat exists, then dir c:\bat\thisdirdoesnotexist\nordoesthisone\..\.. will show the c:\bat directory. Again, absolutely useless as far as i can tell , but interesting. BTW, has anybody solved the "dir ..." mystery yet? I also noticed "dir \..." works while "dir \bat\..." fails (any explicitly specified directory other than the root generates an "invalid directory" message). Paul Leonard Regarding the 'point' notation/wildcarding, the situation is that "point-notation" is recognized at the INTERRUPT-level by some DOSs/some interrupts. It is *not* a MUF in the sense (A) that it *is* documented in any comprehensive Int Reference Manual; (B) it is *not* specifically "available" to/from certain DOS (etc) commands, it is rather "passed-on" without syntaxing (maybe) to the BIOS-level functions, which may or may-not recognize it, dependant on what OEM and HARDWARE you have, and is relatively *IN*dependant of whatever DOS you are currently running. In Other Words: it's a documented Freebe/Maybe --- at the BIOS/INTERRUPT level! nb. Anywhere single-dot notation (current directory) is accepted/works, so will double-dot '..' (and maybe triple-dot, etc!!) This is a _very_ good way to accidentally *trash* your ROOT directory!! '..' => "parent of current directory" '...'=> "parent of parent of current directory", etc; although in some implementations a '\' may be needed following the last '.' I think the CD question ("CD\" as opposed to the documented "CD \") is in the same category: it is not-even an MS *Function* per se, but is rather 'recognizable' by the BIOS functions which the Command-Parser relies upon. Don Hoffman DIR *. To be exact: this (DIR...) shows all files and directories without extension, just like DIR *. (tested under MS-DOS 5.0) Horst Schaeffer You are right! I am surprised. DIR *. will list directories, but no files! Per Kristensen This one doesn't only show subdirs, it also shows files without extension. Rene Verhagen If the directory is empty, the above will fail. Vernon Frazee =============================================================================== 12) DRIVPARM DRIVPARM /c Syntax: DRIVPARM /d:number [/c] [/f:factor] [/h:heads] [/i] [/n] [/s:sectors] [/t:tracks] /d:n refers to the drive NUMBER (0=A:, 1=B:, 2=C:, etc...) of the drive whose parameters you are changing (in your case, it would be 2 for B:). /c is the switch I was referring to for change line support. IF YOU INCLUDE /c, YOU ARE TELLING DOS THAT YOUR COMPUTER *CAN* TELL WHETHER THE DRIVE DOOR HAS BEEN OPENED SINCE THE LAST ACCESS. /i specifies an electronically-compatible 3.5 inch floppy disk-drive. You should use it if your computer's ROM BIOS does NOT support 3.5 floppy diskette drives. /n specifies a NON-removable block device The other parms are similar to DRIVER.SYS IBM Technical Publication Information forwarded by Andrew Barnhardt The '/C' switch doesn't actually check to see if the drive -door- has been opened or not, but it does make another check to see if the disk in there now is different from the one when the drive was last accessed. I have to use that switch with my 5 1/4 floppy because it's an older drive working with a new motherboard (at least that's the explanation I've heard). Andrew Barnhardt Does DRIVPARM return an errorlevel, or give a warning message? Gary Cooper No, not that I'm aware of. You insert the drivparm command in your CONFIG.SYS file. Just DRIVPARM=xx xx ... Andrew Barnhardt =============================================================================== 13) ECHO ECHO OFF from the command line erases the prompt and leaves just a cursor on the screen. ECHO ON from the command line restores the prompt. This works with all version of DOS (tested so far!). Michael Larsson EDITOR'S NOTE: One of the most frequently asked questions in the BatPower echo is "How do I ECHO a blank line?" The most common answer is "ECHO." However, I have captured a few posts which expand on the possible answers to this request: ECHO" Paul Welsh just about any white space character will work. Alan Newbery I just found out myself that any delimiter will work here (ECHO. ECHO" ECHO, ECHO: ECHO; ECHO[ ECHO] etc.). Apparently it's just the way that the command handles the delimiter and has been available from way back. Microsoft just began mentioning it in the documentation recently, though, and their examples use a period. John Whitfield Different sets of delimiters work in different versions of DOS. Finding one that works in all versions can be tricky, but if I recall correctly, the period works most of the time. Gary Smith Can anyone tell me how to write OFF on the screen - with no preceding spaces, no quotation-marks etc. from a batchfile - and preferable with the ECHO-command? Karsten Weldingh Simple, try: ECHO.OFF Works fine under DOS 6.0! Michael Larsson / Matthew Lewis DOS 5.0, too - where did you find this tidbit? I just tried it with the usual suspects and they work, as well (echo[off, echo]off, etc.). Paul Leonard EDITOR'S NOTE: Regarding the commonly used technique of using: ECHO.|TIME to feed a carriage return / line feed to the MS-DOS TIME command, and avoid the necessity of pressing ENTER in response to the TIME commands' prompt to enter a new time, I captured the following discussion: Just a note, the command: VER|TIME will prove to be a bit faster. Since both are internal commands the elapsed time required for each to execute should prove to be almost identical. We quit using the "echo." about a year or so ago when because of a blurb in PC World (or was it PC Magazine) that said it would reset the time to 00:00 on one of the popular brands of network software. Vernon Frazee "echo. |time" is faster yet, and is abusive of neither DOS nor the user. That would qualify as a bug. I don't think much of introducing buggy "work arounds" for something that NEEDS to be fixed. ("VER|TIME" will hardlock some CLI's, depending on the format VER is presented in... neat: crash a time-check because of an unusual VER format.) Don Hoffman What brand of network software, what CLI's? Gary Cooper I do know from personal experience that VER | TIME _will_ hardlock some non-MS's however... 4DOS 4.0 rev B for-sure. Don Hoffman echo "echo y|del *.* > wipe.bat" > test.bat will create the file test.bat but it contains the line "echo y|del *.* > wipe.bat" which of course will not execute. All you have to do is find a way to delete the double quotes, an intellectual exercise :-) If you find an answer I would appreciate knowing as well. Amer Neely You can use EDLIN to strip the quotation marks out of TEST.BAT with: C:\DOS\EDLIN TEST.BAT < TEST.SCR Where TEST.SCR contains the following: 1,#r"^Z e You will have to create TEST.SCR with an editor which permits you to put a ^Z directly into the document. This is NOT a caret and an upper case "Z", with EDLIN it is F6 or ASCII-26 the end of file marker. For example, in MS-DOS EDIT you can place the ASCII-26 character (a small right pointing arrow) in a document by pressing CTRL-P and then CTRL-Z. Gary Cooper To eliminate the leading double-quote you can do a: echo"echo y|del *.*>wipe.bat ">doit.bat (Note how the two echo's are separated by a single double-quote mark with no space). When the above is executed, DOIT.BAT will contain: echo y|del *.*>wipe.bat " In this particular instance the trailing double-quote mark doesn't really matter (because it is separated by a space from the file extension). But, if it really bothers you, it can be eliminated using EDLIN _without_ worrying about a ^Z ([Ctrl-Z]). Try this: @echo off echo"echo y|del *.*>wipe.bat ">doit.bat for %%x in (echo type) do %%x DOIT.BAT echo 1,1r">temptemp.scr echo e>>temptemp.scr echo. echo EDLIN at work: edlin doit.batfdisk /mbr Warning: Writing the master boot record to the hard disk in this manner can make certain hard disks unusable. IE: those partitioned with SpeedStor, or Microhouse's DrivePro program. It can also cause problems for some dual-boot programs, or for disks with more than 4 partitions. Specific information is below. WARNINGS: This option should not be used if: - the disk was partitioned using Storage Dimensions' SpeedStor utility with its /Bootall option - the disk was partitioned using MicroHouse's DrivePro program AND the drive was NOT setup using a standard CMOS value. - more than 4 partitions exist - certain dual-boot programs are in use Storage Dimensions' SpeedStor utility using the /Bootall option redefines the drive's physical parameters (cylinder, head, sector). /BOOTALL stores information on how the drive has been changed in an area of the master boot record that MS-DOS does not use. FDISK /MBR will erase that information, making the disk unusable. MicroHouse's DrivePro program functions similarly to SpeedStor above, and has the same boot record vulnerability. MicroHouse identifies their boot program at boot-up by a small MICROHOUSE logo near the left side of the screen about two-thirds down, at power on. If you see this logo, do NOT use FDISK /MBR, or the drive will become unusable. Some older OEM versions of MS-DOS and some third-party partitioning utilities can create more than 4 partitions. Additional partition information is commonly stored information on partitions in an area that FDISK /MBR will overwrite. Some dual-boot programs have a special MBR that asks the user which operating system they want on bootup. FDISK /MBR erases this program. Dual-boot systems that boot whichever partition is marked Active are not affected by FDISK /MBR. Edited: MicroSoft Publication forwarded by Don Dean editing suggestions made by Matt Mc_Carthy (info re: MicroHouse's DrivePro) If you have a Boot Sector Virus, just boot from a known "clean" floppy disk (which has the System files and FDISK on it - IE: your "disaster recovery disk") and run FDISK /MBR. Bye, Bye Virus! Gary Cooper Make sure it's write protected. Jasen Betts [Begin quote] One of the FDISK functions, updating the Master Boot Record (MBR), does not appear on any of the FDISK menus. The Master Boot Record is located at the beginning of your primary fixed disk. It is composed of two parts -- the master boot code and the partition table. The master boot code is a short program that determines which operating system will start the computer, then transfers control to that operating system. The partition table contains information about the partitions located on the fixed disk. The Master Boot Record may need to be updated when: * An operating system other than MS-DOS is on the fixed disk. Some operating systems replace the master boot code with their own program, which may not allow MS-DOS to start the system, even if the partitions are valid DOS partitions. If this condition exists, updating the Master Boot Record will replace only the master boot code. * The information at the beginning of the fixed disk has been overwritten. The partition information is destroyed and the fixed disk will no longer start any operating system. If this condition exists, updating the Master Boot Record will replace both the master boot code and the partition table. However, the partition table will not have any defined partitions. If you cannot get your system to start MS-DOS from the fixed disk and you are sure the initialization process was performed correctly, you may need to update the Master Boot Record. To do this, enter the following command: FDISK /MBR FDISK does not display any menus or messages while it is updating the Master Boot Record. When the procedure is complete, the MS-DOS prompt is displayed. If you are unable to start MS-DOS from the fixed disk after updating the Master Boot Record, you may need to partition and format your fixed disk. If you still cannot use the fixed disk to start MS-DOS, contact your Authorized COMPAQ Computer Dealer for further assistance. [End quote] Compaq DOS 4.01 Manual Submitted by Paul Maserang If the situation at hand involved a trashed partition table. This regenerates the partition table, but does NOT restore the user partition information in it. Therefore, after using FDISK /MBR, you must still use FDISK without the /MBR switch to re-enter the partition information before you can do anything else. If the newly entered partition information is identical to that which existed there prior to the partition table being trashed, and nothing else has been damaged, there should be no need to reformat the drive, because the boot sector, FATs, directories, and data should still be undisturbed. If the boot sector or either of the two hidden system files (IBMBIO.COM/IBMDOS.COM or IO.SYS/MSDOS.SYS) are damaged, the SYS command can be used to restore them without losing anything else. Paul Maserang I work _only_ with the Microsoft versions, and have not had the same experience. The /MBR parameter _only_ rewrites the MBR. It does not affect the partition information. I use it daily on various machines and have not lost one byte of data. Matt Mc_carthy I guess you didn't know that "Master Boot Record" and "Partition Table" refer to the same thing. What you're talking about is the master boot CODE, the executable code that accompanies the partition table and is located on the same physical sector (0). Here's what I find in the first few bytes of my physical sector 0 (unassembled with DEBUG after copying the sector to a file): 2BB7:0100 33C0 XOR AX,AX 2BB7:0102 FA CLI 2BB7:0103 BED0 MOV SS,AX 2BB7:0105 BC007C MOV SP,7C00 2BB7:0108 BEC0 MOV ES,AX 2BB7:010A BED8 MOV DS,AX 2BB7:010C FB STI 2BB7:010D 8BF4 MOV SI,SP 2BB7:010F BF0006 MOV DI,0600 2BB7:0112 B90002 MOV CX,0200 2BB7:0115 FC CLD 2BB7:0116 F3 REPZ 2BB7:0117 A4 MOVSB 2BB7:0118 EA1D060000 JMP 0000:061D I also find the following text in the first half of the sector: Missing operating system. Error loading operating system. Invalid partition table. Author - Siegmar Schmidt I have only one partition on my C: drive, and its information is in the last of four possible positions in the partition table. The first significant byte (non-zero) is at offset 01EEh in physical sector 0. The rest, from offset 00EDh to 01EDh is nothing but 00h. So it would appear that everything from offset 0000h to 00ECh is the Master Boot CODE, and everything from 00EDh to the end of the sector (01FFh) is the Master Boot RECORD (aka partition table). More likely, the partition table probably begins at offset 0100h, and takes up the last 256 of the 512 bytes available in the sector. Beginning with the first significant byte of my partition table (at offset 01EEh), this is what mine shows: 80 01 01 04 03 91 65 11 00 00 00 07 A3 00 00 55 AA ^^ This first byte, I think, is the drive on which this partition is located, and the next byte might indicate that this is the first (primary) partition (in my case, the ONLY partition for this drive). Now, according to my manual, FDISK /MBR can either re-write only the Master Boot CODE when necessary; or it can re-write both the Master Boot Code AND the Master Boot RECORD, if it determines that the partition table has been corrupted. If it does re-write both, then you do have to use FDISK without the /MBR switch after using it with the switch, because the re-written partition table has no defined partitions until you do. But when you use the /MBR switch, it produces no screen output (at least not on the version I'm using), so you don't know whether it did both or just the code. So you should still check to see that you have a valid partition by using FDISK without the /MBR switch afterwards. Paul Maserang =============================================================================== 16) FOR IN DO FOR %%V IN (/SOMETHING) LEADING SLASH WITH FOR IN DO LOOP In the FOR statement in the INIT and COUNT routines below the parameters in the () show a leading "/". This seems to separate the first digit of the environmental variable used within the brackets (). Am I correct? Is this documented anywhere? :================= INIT ================= set &=%4&|set n$=%4|set m$=%3|set #=%2|set !=%0 if not '%m$%'=='0' for %%a in (/%m$%z) do if '%%a'=='0' set @=0 %!% :================= COUNT ================ if '%&%'=='&' goto PROCESS for %%a in (/%&%) do set &=%%a Peter Joynson I have read some articles about this in PC Computing & PC Magazine. I don't believe it is documented anywhere but you're right, it strips off the first character of whatever string is passed. I will try to find one of the articles that explains it better if you need it. Robert Hupf Correct. I believe it is not documented (up to DOS 5 anyway) by MS, but I have read from other sources that the leading / will split an item into the first character and everything else. Eg: for %%n in (/hello there) do echo %%n will display "h", "ello" and "there". "There" is not split because it is a separate item, delimited by the space. If used with an item including wildcard (? or *) characters the item will not be expanded to the files which match it, thus allowing inclusion of those characters in the set. Eg: for %%n in (/? /*.bat hello) do echo %%n will display "?", "*", ".bat", "hello". This apparently is the original reason for the feature, but it may also be used recursively to parse a string one character at a time. Mitch Ames ... quoting Dirk Treusch to All ... How can a batch file (without 4DOS) determine from which drive it has been started? Example: C:\> a:test.bat Now my batch should be able to find out that it is located on drive A: (not the path - only drive!). Mitch Ames responds: The variable %0 contains the name of the batch file _as_it_was_typed_at_the_command_line. If you call the batch file as A:TEST.BAT, %0 will be "A:TEST.BAT". If you have the directory on your path, and simply type TEST, then %0 will be "TEST". The drive, path and extension will only appear in %0 if you enter them in the command used to call the batch file (either typed at the command line, or called from another batch file). So you _must_ specify the drive as part of the batch filename for this to work. To extract the drive only, use STRINGS, or similar (I don't have a copy, so don't ask me to post it). Alternatively use the undocumented FOR %%V in /SOMETHING command, eg: set drive= for %%v in (/%0) do call test2 %%v echo Calling drive is %drive% where TEST2.BAT is: if not '%drive%'=='' set drive=%1: Disclaimer - I haven't tested this. Debugging is up to you. (You can, of course, fit this into a single recursive batch file - but that's left as an exercise for the student.) FOR %%V IN (/SOMETHING) DO WHATEVER will do WHATEVER twice - the first time with %%V set to the first character in SOMETHING ("S"), the second time with all the remaining characters in SOMETHING ("OMETHING"). If SOMETHING is only a single character, WHATEVER will only be called once, with that character in %%V. If the single character is a wildcard (? or *) that wild card will _not_ be expanded to a set of filenames. (The main purpose of this feature is apparently to allow inclusion of the literal characters "?" and "*" without them being expanded.) This works in DOS 3.30 and 5 - I don't know about other versions. Mitch Ames Example: I can get the date from the PC or from a file date stamp, but it's in the format MM-DD-YY. I need it have the same date echoed in the file name CDYYMMDD.ext Brent Myhand The only way know to accomplish this in pure DOS is to use an undocumented feature of the "for" command. If the "set" starts with "/", for responds twice, once for the first character and once with all the remaining characters. To see this, at the DOS prompt try: for %x in (/abcde) do echo %x You'll get "a" and then "bcde". So the general idea is to strip off characters one at a time and build the new string. The problem is that the command after the "do" looks the same for the two passes. The only feasible command seems to be to call another batch file, which can get you pretty deep into nested calls if you're not careful. To distinguish the first and second call, you can set an environment variable before the first call to "STEP1," and have the place called change it to "STEP2." To prevent the nesting per character, you can have the "STEP2" call save the remainder string in an environment variable and iterate at the main level. I think you'll also need a flag to tell you if you're working on the Month, Day, or Year part of problem. And, do you really get a 2 digit year, or do you get a 4 digit year? I think this does it: %echo off if NOT (%1)==(MORE) GOTO INIT if (%STEP%)==(STEP1) GOTO STEP1 if (%STEP%)==(STEP2) GOTO STEP2 GOTO END :INIT set STEP=STEP1 set STR=%1 set STAGE=M set DAY= set MON= set YEAR= set YYMMDD= :LOOP for %%x in (/%STR%) do CALL %0 MORE %%x if (%STR%)==() GOTO FINISH GOTO LOOP :STEP1 set STEP=STEP2 set STR= if (%2)==(-) GOTO NEWSTAGE if (%STAGE%)==(D) set DAY=%DAY%%2 if (%STAGE%)==(M) set MON=%MON%%2 if (%STAGE%)==(Y) set YEAR=%YEAR%%2 GOTO END :STEP2 set STEP=STEP1 set STR=%2 GOTO END :NEWSTAGE if (%STAGE%)==(D) set STAGE=Y if (%STAGE%)==(M) set STAGE=D GOTO END :FINISH SET YYMMDD=%YEAR%%MON%%DAY% set STEP= set STAGE= set DAY= set MON= set YEAR= :END If you need to trim 4 digit years down to 2 digits, you'll need to add some STAGES. William Lipp The / causes the FOR command to break %1 into two parts: the first character of %1 and the rest of %1. Take the line: for %%v in (/%1) do set word=%%v Say that %1 equals Lang, first time through word will be set to L, second time though it will be set to ang. Without the / it would be set to Lang. This is a very useful trick to know. Scott Lambert From the command prompt type in for %x in (/abcd) do echo %x You will get "echo a" followed by "echo bcd". The leading "/" causes "for" to split the string into the first character and the tail. if %1 is abcd, then line for %%v in (/%1) do set word=%%v results in set word=a set word=bcd so word ends as "bcd". then the line for %%v in (/%1) do if %%v%word%==%1 set char=%%v results in if abcd==abcd set char=a if bcdbcd==abcd set char=bcd so char ends as "a" The other lines handle the case where %1 is only one character. William Lipp ... why won't this work: for %%f in (/h /H -h -H /? -?) do if "%1"=="%%f" goto @Help Rene Verhagen What you could do to override this problem, is very simply write: for %%f in (H h ?) do if "%1"=="/%%f" goto @help for %%f in (H h ?) do if "%1"=="-%%f" goto @help Raphael Neve & Gary Cooper The H and h should work, but the "?" inside a for-in-do is expanded by command.com into single-character filenames, so it would probably give unexpected results. Gerry Pareja There are two problems here. First problem is, when you use a ? or a * in the FOR set, it looks for files that match the wildcard specification instead of using the actual ? or * in the string. Second problem is, the / calls up an undocumented feature of the FOR command. Try this from the command line: FOR %I IN (/12345) DO ECHO %I It loops twice, the first time produces a "1" and the second time produces "2345". If there's only one character after the / it loops once with just that one character. We can do what you want, but we have to split the loop into two lines. One to check for the /switch and another to check for -switch for %%i in (h H /?) do if "%1"=="/%%i" goto help for %%i in (h H /?) do if "%1"=="-%%i" goto help Because of the way / works in FOR sets, the /? sends a plain question mark instead of "/?" or a list of one-character filenames. Steve Reid ADDITIONAL FOR IN DO WEIRDNESS: Why does the following not work as expected? for %%z in (test1 test2 test3) do goto %%z goto end :test1 echo test1 :test2 echo test2 :test3 echo test3 :end Greg Frizzle GOTO commands in FOR IN DO statements do not work correctly/as expected. This fragment will work in 4DOS, but not with COMMAND.COM. You've seen what happens when running under COMMAND.COM already. 4DOS will display test1 test2 test3. I was trying to explain... that GOTO's don't work right, and that IF's will break FOR IN DO's. Bill George I fell for this, too. The strange thing is (on my MS-DOS 5 system), the output from this batch file is test3 I don't know why it doesn't go to label test1 and then fall through to :end Jim Long I have been unable to break a FOR IN DO with an IF, nor do I find that GOTO's function incorrectly. I suspect that there might be some confusion here with the function in BASIC known as GOSUB. Peter Lovell Bill George's point is a valid inclusion, I believe, because GOTO's in a FOR IN DO statement do not work the same way that other FOR IN DO's do. The FOR IN DO is only processed until the first GOTO is executed, and does not repeat for all members of the 'IN (set)' in the same way that MS-DOS treats other FOR IN DO loops (i.e. it doesn't.(loop)) As far as IF's breaking FOR IN DO's I've had no experience of any inconsistency and sadly BG's comment gives no examples. I've tried several methods but cannot find any unexpected failures. Mark J. Allen I finally figured out how to manage some crude edlin scripts, but found a serious weirdness: when running it under 4dos, it tends to endlessly loop. I can't figure out why... for %%a in (*.xxe) do edlin %%a < do.scr And what I've found is that the batch will loop on it's own, so that do.scr puts the text in each *.XXE file two or three times. Todd Jacobs I've got the feeling I'm not going to be able to explain this particularly clearly, but here goes... The reason for the looping is that the "for..in..do" loop will go and get the next filename as it executes, rather than building a table with the filenames in it and going through the table. So, if you have three .XXE files, the loop executes three times, then checks to see if there's a fourth file - and it finds another three, namely the "new" versions of the original three which have been edited and are now sitting somewhere else on your disk. So it processes what it thinks are files four, five and six, then looks for a seventh - and finds the same three files edited yet again to look like files seven, eight and nine. I believe this only occurs when the order of the files in the directory - bearing in mind that the true order may not be visible to you if you have overridden it with DIRCMD - is affected by the operation which is being carried out in the loop, so for example, merely reading the files will not cause this "weirdness", but EDLINing them will, since the original file is renamed .BAK and a new image of it is created elsewhere on the disk. Rudy Lacchin I want to see if an environment variable is equal to 00, and if it is, change it to --. Something along the lines of: set z=00 for %%x in (%a% %b% %c%) do if "%%x"=="%z%" set %%x=-- Can this be done? David Farrington :--- Initializing some variables --- set A=VA set B= set C=00 :--- Your code --- set z=00 for %%x in (%a% %b% %c%) do if "%%x"=="%z%" set %%x=-- set :END This will show the following: A=VA C=00 Z=00 00=-- Not quite what you wanted, but the effect is interesting and worthy of saving in one's little bag of .BAT tricks. That is, one can set a variable whose name is in a FOR index, derivable from another variable or argument (or, I assume, the name can be given directly via another variable or an argument). I was going to say, "the answer to your problem is simple" and proceed to change your code by merely taking out a '%' or two. But it doesn't seem possible. The straightforward way to do it is not to use FOR at all, but simply IF "%A%"=="%Z%" SET A=-- IF "%B%"=="%Z%" SET B=-- IF "%C%"=="%Z%" SET C=-- Terribly mundane, however. The challenge you pose relates to a question I asked more than a month ago, and which stumped me for a similar reason: it seemed impossible to retrieve the CONTENTS of an environment variable when its NAME is itself given as any kind of variable (an environment variable, an argument, or a FOR index - anything requiring a percent sign for its expression). However, you have inspired me to give the problem a little more thought, and I have found a way out, although it requires a batch file to write and run another batch file. The key to this is that '%%' in an ECHO statement gives us a single literal '%'. (If for some reason this does not work, perhaps you can still SET PCT=%% and get '%' as %PCT%). Now, if we have PTR=NAM and NAM=VAL, we can get VAL from PTR thus: ECHO SET GOTIT=%%%PTR%%% >TMP1.BAT CALL TMP1.BAT DEL TMP1.BAT ECHO The answer is %GOTIT% A similar technique will do what you want using FOR. It is convoluted and relatively impractical with only three elements; but if you had many to check, or if any of the components of FOR() were themselves a variable, it might become an empowering tactic: if "%1"=="DO1" GOTO DO1 set A=VA set B= set C=00 set z=00 for %%x in (a b c) do call %0 DO1 %%x %z% del TMP1.BAT goto end :DO1 echo IF "%%%2%%"=="%3" SET %2=-- >TMP1.BAT call TMP1.BAT :END I am intrigued by this as a programmer in the C language, where (as you probably know), indirection by means of pointers is ubiquitous. It is common to use a pointer to refer to an element of an array. It is less common, but still often useful, for a pointer to mark one of several scalar variables. At run time this is done via addresses, of course, not names. However, in batch language, environment variables do not have addresses in any practical sense, and their names are all we have by which to grab them. Although the .bat application which first caused me to think about this issue is long forgotten, I remain hopeful that if we keep it in mind as a live option, uses will occur to us. Paul Emmons On Sunday February 06 1994, Rob Flor wrote to Quang Sun: QS>> For %1 in (TEFILE tefile GWS gws) do Goto %1 RF> ^ ^ RF> ÄÄÄÄÄŁÄÄÄÄÄ should be %%f ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŁ RF> where "f" is RF> alphabetic, not numeric. I've seen a few people state that the control variable in a for..in..do loop must be a letter, but %%1 and even %%? work just as well. No? Rudy Lacchin I tested this and it works without a hitch even when there is a %1 variable on the command line? Gary Cooper Unfortunately, FOR-loops cannot be nested. If they could, we could say: for %%f in (h H /?) do for %%g (// -) do if "%1"==(%%g%%f) goto @Help Rene Verhagen It *is* possible to nest FOR loops, by using COMMAND /C... for %%f in (A B C) do command /c for %%g in (1 2 3) do echo %%f%%g Steve Reid for %%b in (zip arj arc lzh nws gif exe msg txt) do... ...if exist *.%%b goto files >nul Terry Jackson Your above example is working fine here under MS-DOS v6.22. Vernon Frazee for %%b in (zip arj arc lzh nws gif exe msg txt) do... ...if exist *.%%b pcopy *.%%b \tlxdump /x/ba >nul The if exist still doesn't seem to work in this one. Terry Jackson Give it a try by CALLing PCOPY; like so: ...if exist *.%%b CALL pcopy... Vernon Frazee =============================================================================== 17) FORMAT EDITOR'S NOTE: This section contains a discussion about how one may format a disk(ette)s by the quickest means available. It is most difficult to separate the various suggestions as the discussion blends from one proposed method into the next, please bear with the text. FORMAT A: /AUTOTEST The autotest parameter will allow format to proceed, checking existing format (unless the /u parameter is also present) and proceeding with the format. All this will take place with no delay and no waiting for user input. It will also end without pausing. It will not ask for a volume label or whether to format another diskette. WARNING! This procedure will also work on hard drives! Be very cautious if you plan to use this feature. Wayne Woodman FORMAT/U is not available in DOS 3.30 Mitch Ames It won't take any other switches like /U, /S or /Q which is a bit of a shame really. When I try it with Dos6 I get the following error message: Parameters not compatible. Format Terminated. Peter Lovell /U and /S both work together with /AUTOTEST with my copy of MS-DOS 6.00. Did you possibly use an illegal combination of switches? John Evans With Dos 5 it certainly takes /u and /s as I have used it, in fact I think /u is required if the disk is not pre-formatted as the drive hangs up otherwise. I would agree about /q though, this does not work and gives the error message you quote. Terry Kreft Have you ever tried: FORMAT A: /Q /U /AUTOTEST Pete Dinnella This doesn't work in my DOSs (IBM DOS 5.02 and OS/2). You can't combine /Q AND /AUTOTEST Asbjorn Hojmark I have loaded my F5 key with ANSI.SYS so when I press it I get FORMAT A: /F:720 /U /AUTOTEST This DOES work. Pete Dinnella EDITOR'S NOTE: In response to requests for the fastest way to format diskettes. Vernon Frazee has offered the following solutions. These techniques generated a great deal of discussion pertaining to the validity and relative merits of each method. REN /?|FORMAT %1 /q /u /v:"%2">NUL Most of the solutions I've created and used, or seen... echoed the necessary responses out to a temporary file, redirect the contents of that file back to the FORMAT command, and then deleted the file. Inefficient! If you type the command: format a: /q /u /v:"" FORMAT will 'quick format' a diskette in A:, unconditionally, and without prompting for a volume label, which is all well and good, BUT for many, the two prompts: Insert new diskette for drive A: and press ENTER when ready... and then: QuickFormat another (Y/N)? get real old after a while. We DON'T have time to play. We wanna slam a disk in the drive, hit a few keys and have a formatted disk ready to go... now! The solution of course is some way to send a "carriage-return" response to the first prompt, and then a "N" and "carriage-return" to the second. And, like I stated above, most use a temporary file to store these keystrokes and then delete it. Well check it out. If you're using MSDOS v5.00 or higher (haven't tried it with anything earlier yet) stick a previously formatted diskette in drive A: and try the following command: ren /?|format a: /q /u /v:"" and the text generated by the "REN /?" portion of the command lands you back at the DOS prompt no questions asked! Yea yea, I know, the output is ugly but hey, it works! If you'll simply add a ">nul" (not the quotes) to the end of the line it'll hide the mess. Here's my QF.BAT(ch) solution built around the above: @echo off :QF.BAT - Quick Formats diskette in specified drive (with : optional volume label). Type "QF /?" for syntax for %%x in (a A b B) do if (%1)==(%%x:) goto BEGIN for %%x in (a A b B) do if (%1)==(%%x) QF %1: %2 :Syntax ................................................. echo Syntax: QF d[:] [volume_label] echo Where: d is either drive A or B, (":" optional) echo and: volume_label is an optional volume label goto END :BEGIN .................................................. echo Quick formatting diskette in %1... if not (%2)==() echo and adding label "%2" ren /?|format %1 /q /u /v:"%2">nul echo Task complete. :END .............................................. -vjf- If you'll stick the above in a directory in your PATH all you have to do to 'quick format a diskette in A:' is type: QF A (or "QF B") and you'll have "no questions ask" formatted diskette ready to go in 7-8 seconds. Vernon Frazee EDITOR'S NOTE: This shorter version of QF.BAT eventually evolved into the following: "a BATch file named QF (Quick Format) that ONLY allows formatting diskettes in drive A: or B:. The entire BATch file is built around the single command (which I use in a DOSKEY macro instead of a BATch file): ren /?|format %1 /q /u /v:"%2">nul Here's my QF.BAT solution (again): @echo off :QF.BAT v1.1 ----------------------------------------------------------- :Purpose: Quick Formats diskette in specified drive (with : optional volume label). Type "QF /?" for syntax for %%x in (a A b B) do if (%1)==(%%x:) goto BEGIN for %%x in (a A b B) do if (%1)==(%%x) QF %1: %2 :Syntax ---------------------------------------------------------------- echo Syntax: QF d[:] [volume_label] echo Where: d is either drive A or B, (":" optional) echo and: volume_label is an optional volume label echo Note: DOS's CHOICE.COM is used if an error occurs goto END :BEGIN ----------------------------------------------------------------- echo Quick formatting diskette in %1... if not(%2)==() echo and adding label "%2" ren /?|format %1 /q /u /v:"%2">nul if errorlevel 4 goto ERROR if errorlevel 3 echo Task terminated. if errorlevel 3 goto END if errorlevel 0 echo Task complete. if errorlevel 0 goto END :ERROR ----------------------------------------------------------------- echo. echo Error reading drive %1! echo. echo a) Is the disk inserted correctly and the drive door closed? echo b) Maybe the disk is write-protected or "%1" is the wrong drive? echo c) Has the disk in drive "%1" ever been formatted before? echo (QF won't work on a disk that's never been formatted). echo. choice /c:ar Your choice: Abort or Retry echo. if errorlevel 2 goto BEGIN echo Task aborted. :END ------------------------------------------------------------- -vjf-" Vernon Frazee EDITOR'S NOTE: In response to these suggestions Vernon received the following feedback: If you type the command: format a: /q /u /v:"" FORMAT will 'quick format' a diskette in A:, unconditionally, and without prompting for a volume label, which is all well and good, BUT for many, the two prompts: Vernon Frazee Have you ever tried: FORMAT A: /Q /U /AUTOTEST The undocumented /AUTOTEST switch will not ask you to insert a disk nor will it ask for a volume label or if you want to format another! I have loaded my F5 key with ANSI.SYS so when I press it I get FORMAT A: /F:720 /U /AUTOTEST (I use a lot of 720k 3.5's) Now with the press of a single key I pump out a 720 floppy pretty damn quick! Try it! P.S. I know this works with DOS 6.0. Don't know about 5.0 and below! Pete Dinnella I did... on every version of MS-DOS since 4.0. And neither of the undocumented FORMAT parameters, "/AUTOTEST" or "/BACKUP" will work with the "/Q" parameter. In fact both return the same error message: format a: /q /u /v:"" /autotest and, format a: /q /u /v:"" /backup return the error: Parameters not compatible. Format terminated. Vernon Frazee Question, Why not redirect a text file with the necessary keystrokes in it to the format command? William Johnson 1) If you store the "text" file on the hard drive permanently it's: a) Wasting a minimum of one cluster and b) You have to wait for DOS to find and read the file (so it can redirect it to the FORMAT command) 2) If you are echoing the keystrokes out to the "text" file instead, you have to wait for: a) DOS to write the file b) DOS to find and read the file (to redirect it to FORMAT) c) DOS to delete the file Vernon Frazee You did great down to here, Vernon! The rest is wrong. VF> ren /?|format a: /q /u /v:"" is faster because it uses REN (a DOS command already in memory). (It doesn't have the additional delay of reading and/or writing the extra "text" file to and/or from a slow mechanical disk). To test what I'm saying, Vernon, use a .BAT such as this: @echo off set xemp=%temp% set temp=a:\ ren/?|format b:/q/u/v:"" set temp=%xemp% set xemp= If you want to read the output of REN/? from drive A:, just UNDELETE the newest file on drive A: and read it. If I remember right, the pipe puts TWO temporary files on disk that have to be deleted. One of those is zero length and can't be read but it's still an additional file that must be written and subsequently deleted from the disk. It seems that this should be covered in the DOS manual but if it's there, I've never seen it. Billy Gilbreath EDITOR'S NOTE: In response to another suggestion from Vernon Frazee. FORMAT A: /Q /U /S /V:"" /F:1.2 Vernon Frazee /Q and /U are mutually exclusive options. Actually, it just kind of ignores the /q. Also putting the "/U" is really unnecessary unless you have reason to suspect bad media. If "/Q" cannot determine the media type, it defaults to "/U" format. Steve Adams /Q is not kind of ignored at all. /U is by no means unnecessary, if you do not use it then format will check the disk and save the "Unformat" information, this takes time, try doing a quick format with /U and without it, the difference in processing time is significant. Also /Q does not "default" to /U format, it asks for user input as to whether it should proceed with an unconditional format, sometimes! Following this message I spent two hours playing around with FORMAT, and the number of responses it gave to differing conditions was quite remarkable. For instance when I said that /Q does not default to /U but requires user input sometimes I was referring to the following cases: MSDos 6.20, 1.44m floppy drive: 1.44m floppy disk, unformatted. Command line> FORMAT A: /V:"" /Q /F:1.44 The user is _not_ asked whether to carry out an unconditional format, FORMAT just carries on and does it. 720k floppy disk, unformatted. Command line> FORMAT A: /V:"" /Q /F:720 The user is _not_ asked whether to carry out an unconditional format, FORMAT just carries on and does it. So what does the following command line do (1.44m floppy disk): Command line> FORMAT A: /V:"" /Q You would think that this should work the same as example (1) above as the /F:1.44 should be implied. It doesn't, the user is _asked_ whether to perform an unconditional format, it does not just carry on and perform one. I found a number of anomalies in the way format handled different disk sizes in the above set-up and the conclusion I reached was that it was unsafe to reach a conclusion on _anything_ format will do, without trying the specific situation out first. The one thing I did find though was that /U gives significant speed improvements in all situations (maybe! ). Why do you use the /f switch with format /q as it is redundant, the /q forces the disk size to be retained anyway. Please see below for a test of this I did. DOS screen capture Comments ============================================ ======== C:\format a: /q /u /v:"" /f:1.44 +- Note /f:1.44 Insert new diskette for drive A: | and press ENTER when ready... | | Checking existing disk format. | QuickFormatting 720K +- Note its actually Format complete. | formatting to 720k | as this was the | original disk 730,112 bytes total disk space | size. 730,112 bytes available on disk | | 1,024 bytes in each allocation unit. | 713 allocation units available on disk. | | Volume Serial Number is 3F2D-13DE | | QuickFormat another (Y/N)?n | | C:\ +- Done So as I say the /f is redundant. Terry Kreft FORMAT C: /BACKUP This week I've read some articles in Dutch computer magazines about MUF's which are very interesting (if you don't already know about them). I already knew the FORMAT option /AUTOTEST, but new to me was the /BACKUP option. EXAMPLE: FORMAT A: /BACKUP It seems to work exactly like /AUTOTEST, but it DOES ask for a volume label. Willem Van.den.broek FORMAT/SELECT/U is like DOS-Mirror... for safety-fanatics only FORMAT/SELECT/U makes disks unreadable (remember the U) Reinhard Kujawa Info from The German magazine PC PRAXIS FORMAT /SELECT calls MIRROR after formatting. Patrick Feisthammel Here's a rough translation of what my DOS6 book (written by Hans C. Nieder) says about it: /SELECT/U This is a very dangerous option. Within 1 to 2 seconds, and without further prompting, the disk(ette) will be unformatted in such a manner as to make recovery impossible. This might prove useful for reasons of data protection, e.g. destroying sensitive data. John Evans FORMAT /H In DOS 3.30 (I don't know about other versions), FORMAT /H will cause the format to begin immediately after pressing Y in response to "Format another?", rather than displaying "Place disk to be formatted in drive A: and press Enter" on a second and subsequent disks. Mitch Ames On 5.0 it comes back as "invalid switch". John Mudge =============================================================================== 18) IF EXIST IE: IF EXIST EMMXXXX0 GOTO APPLICATION This is a handy quirk of DOS - installable drivers are seen as files in all directories. You can use the if exist test to either test for the existence of a directory, with "if exist \nul", (which fails if the directory does not exist because the nul device is not found,) or to test whether a driver is loaded. Caveats: you need to know the name of the directory or the driver whose existence you are testing, and this is MS/DOS specific - it doesn't work on network drives, and may not work under DR-DOS. Gary Marden This works definitely under DRDOS: DR DOS Version 6.0 Copyright (c) 1976,1982,1988,1990,1991 Digital Research Inc. Alle Rechte vorbehalten. C:\>if exist emmxxxx0 echo ja ja Wolfram Serber Where did you learn the "EMMXXXX0" name from? Instead of typing MEM /C, type MEM /D for the "debug" listing. That should give the names you're looking for. Erik Ratcliffe The trouble is, EXISTS returns TRUE for COM3/4 and LPT2/3 even though the hardware does not exist. Rudy Lacchin if exist ?:\nul does not return true on cd rom drives. This can be a very effective copyright protection scheme for programs distributed on cd rom disc. If the program is copied to another media it won't run because "if exist :\nul" will be true. (Provided the author included such a check in their code.) Terry Blount Verified this works with 4DOS too. Legal devices were XMSXXXX0, DBLSSYS$, CLOCK$, NUL, AUX, PRN, CON, COM1 thru 4, and LPT1 thru4. All returned yes to the statement: if exist device echo yes Bill George "If Exist" will only check for the existence of a file, but there is a "Loophole" or "Quirk" in DOS that you can take advantage of. Although they never show up in a DIR listing, any DOS DEVICE will show up a file to If Exist d:\path\devicename command and it will return true if the directory "d:\path" exists. Matthew Lewis A little known quirk of the above, it will *always* say that the directory \dev exists, even if it doesn't. Try it and see. if exist \dev\nul echo yep It's just Dos trying to be like UNIX. In UNIX, the devices exist *only* in the /dev directory. Steve Reid =============================================================================== 19) INSTALLHIGH I think I may have found an undocumented feature for DOS 6.... I wasn't able to find this anywhere in the online help. It's called INSTALLHIGH= and amazingly enough it works just like INSTALL= but loads the file high! The only drawback to this is: Memmaker will not go through and add switches for that particular line during the "optimizing process". It just takes it as it is currently. But then again INSTALL= is ignored too! Example: DEVICE=C:\DOS\HIMEM.SYS DEVICE=C:\DOS\EMM386.EXE NOEMS HIGHSCAN WIN=F500-F7FF WIN=F200-F4FF dos=HIGH dos=UMB installhigh=c:\dos\share.exe Robin Francis MUF reported in the magazine C'T: You can use the DOS 6.0 command "installhigh" in config.sys to load TSR programs into UMA. A 48 byte environment will be added for every program. If you use it you don't need the "loadhigh" in autoexec.bat any more. But Memmaker can't handle installhigh! Thomas Erbe Further to Robins explanation, INSTALLHIGH cannot be directed to a specific UMB area and thus defaults to largest currently available. Like INSTALL it is processed (about) last of C.SYS lines and causes more consumed RAM overhead than calling TSR from A.BAT or later. Richard Pade There is an undocumented CONFIG.SYS command called INSTALLHIGH. It is similar to INSTALL except that it will load the TSR into an UMB. It is available under DOS 6. However, it does not support the /L and /S switches that DEVICEHIGH and LOADHIGH support. Tom Dyas Then it is useless, isn't it? It has less than the capabilities of LOADHIGH and DEVICEHIGH but load the same TSRs that they load... no wonder it is an undocumented command. Wayne Moses Just wondering, does INSTALLHIGH work with Microsoft DOS 5? It would also be nice to know why it is undocumented. It doesn't do anything major! Microsoft gains nothing by keeping it undocumented. Loading TSR's from CONFIG.SYS is better because an environment is not allocated for the TSR. A very small amount of memory is conserved, but it is still conserved. Tom Dyas =============================================================================== 20) MEM MEM /A or MEM /ALL Playing around with DOS 6.2 MEM command, I recovered a undocumented Option (at least undocumented in the german version). MEM called with option /? explains 5 options: /D(EBUG), /F(REE), /M(ODULE), /C(LASSIFY) /P(AGE) Not mentioned is the option /A(LL). I compared the output of a plain MEM-cmd and the output of MEM/A; the only difference is following additional line: Freier Speicher im oberen Speicherbereich 1K (864 Byte) (Free memory in high memory area (HMA)) /A is the only option forcing this statement. Michael Dehlwes It is not documented in my English copy of DOS 6.2 either, but does work exactly as you (MD) described. John Mudge If you do a MEM /A it'll give you details of what's in the first meg of memory. Windoze owners get MSD.EXE (a pretty undocumented utility), that tells you this sort of thing. If you do a MEM /A it'll give you details of what's in the first meg of memory. Ben Davis What is this MEM /A in the MUF list supposed to do? Ben Davis says that it's supposed to "give details of what is in your first meg of memory." Don't the /P, /C and /D switches already do that? When I ran it here under DOS 5.0, I got an "invalid switch." Bruce Bowman I am wondering if the switch "ALL" is documented in any DOS manuals? It's not in the HELP command or the MEM /? command, but it is a functioning switch and it is in the code, /ALL reveals free HMA. This is the MEM from the 6.22 Step-Up dated 5-31-94. Is this available in prior versions? Chad Wagner It is avail in my 6.20... I too, was unable to document the /ALL switch, either in the O/L help or in the 6.0 'manual'. Bat Lang MS-DOS Version 5.00 Invalid switch - /all That's what I get when I try to run that command line here. Darren Ryall It's not in the PC-DOS 6.3 manual, certainly, but it's available as a parameter both there and in MS-DOS 6.20. John Gray =============================================================================== 21) MOUSE MOUSE /U Microsoft mouse driver version 8.1 has a /U switch. Adding that switch loads all but 3.3k of the driver into HMA. It's not quite the most recent version mouse driver, but hey, a mouse driver is a mouse driver is a mouse driver, right? Especially when it only takes 3.3k of ram! Mark Carter Are you getting that result by loading the mouse driver high on a 286? If so, that is good news. Mine takes up 12k of main RAM (MS mouse driver ver. 7.0). Gerry Pareja Mouse 8.0 _is_ able to load itself into HMA (I think) on a 286 by using the undocumented /U switch. I read it in PC Magazine sometime back. Also, PC Mag said that the BUFFERS have to be set to a low value, e.g. 5. Ng Cheng Kiang =============================================================================== 22) MULTIPLE DOS COMMANDS ON ONE LINE set &=%4&|set n$=%4|set m$=%3|set #=%2|set !=%0 /|\ /|\ /|\ /|\ |_________|_________|________|____________Separators The separators (|) used in the line, are these doing anything other than separating commands? Can this be used for entering multiple commands on any line in a batch file regardless of type of command? Peter Joynson I believe you are right about this, but I think it pipes any output from the previous command to the next one (your example doesn't have any output. For example: ECHO Y|ERASE *.* This would pipe the Y to the command ERASE *.* so you wouldn't have to enter the Y for the "Are you sure" prompt. Robert Hupf The | is a pipe symbol, well documented in your DOS manual. (Read it before you read the rest of this message if you don't know about pipes already, otherwise the rest won't make sense.) Pipes can be used to put multiple commands on a single line, provided that the first command does not write anything to StdOout which might cause a problem when read by the second command as StdIn. Also, it is assumed that you don't want to see the output of any but the last command, since each command's output will be piped to the next's input. Note that in this case SET neither writes anything to StdOut nor reads StdIn. Thirdly, you must have write access to the current drive, or %temp% if defined, since a pipe always creates a temporary file. Eg this would not work if run from a write protected floppy (unless %temp% was defined), since DOS would fail to create the temporary files. Pipes create temporary files even if no actual data is sent to StdOut because Command effectively treats this: prog1 | prog2 as something like this: prog1 > %temp%tempfile prog2 < %temp%tempfile del %temp%tempfile Even if prog1 doesn't create any output, at least one zero length file is created. To demonstrate, try this set temp= set | dir I must say this beats the usual boring old "how do I echo a blank line in a batch file" etc. Mitch Ames I've done my share of DOS batch file programming but I just stumbled across this this evening. Oh, I've known about ^M for some time but saw them only as a pain in DOS->Unix file conversions. I never thought about "power using" them under DOS. I mean, gee, we have our ANSI.SYS driver, don't we? If I were to it under Unix I would: if [ -f bonk ] then echo "yes, bonk exists!" echo "take a look:" ls -l bonk fi notice the number of commands we can execute in this "nifty" conditional statement. What I found that you can do under DOS is: if exist bonk echo yes, bonk exists^Mecho take a look:^Mdir bonk BTW, those "^M" are control-em's (ASCII 13) Pat Goss This works as is under 4DOS, but COMMAND.COM prefers a space after the ^M's. It *assumes* that there are ^J's there. Maynard Hogg I will tell him that even if the file doesn't exist it will still do: echo take a look:^Mdir bonk Chad Wagner What versions of DOS is this supposed to work under? I tried it with 4DOS, and it executed the second ECHO and the DIR whether the file exists or not. Same thing running under MDOS' COMMAND.COM (MDOS is OS/2's DOS emulator). Scott Wunsch ECHO.| TIME > TIMER.TXT Would the pipe also work with del, ie Y|del *.* Jeff Earle =============================================================================== 23) PATH With MS-Dos 6.0 you CAN exceed the normal path length limit by putting a "Set Path=C:\;..." in your Config.Sys file instead of your AutoExec.Bat file. The usual limits do not apply there. I have put in a path well over 800 characters and it works fine. The path doesn't display correctly via PATH or SET, but it's in there and it all gets searched. I don't recommend having a path that long, mine is normally only 6-8 directories. Andrew Barnhardt To change drive you need not extract the drive from the path. If you have the path %P% for example, just do: %P%\ cd %P% Works with MS-DOS, Novell DOS (Don't know about 4DOS, PC-DOS). Horst Schaeffer Indeed it does work with MS-DOS. The backslash at the end of the path is vital. Fortunately, it makes no difference if there are two or more. Gary Smith That trailing backslash certainly does the business - I've always stripped the D: never thinking that the simple addition of a backslash would save lines of code. I've never seen this before but can confirm that it works flawlessly with MS-DOS v5.01a. Mark J. Allen Funny thing is: the path does not have to be valid, even some delimiters will do the job, for example: D:\\ D:NUL\ D:;=,\ But it will fail with wildcards (!) Horst Schaeffer Why do you want to peel off the drive letter and colon? Aren't they part of the current directory? Phi Nguyen As a simple example, if you're on drive H: in the \FOOBAR directory and you need to get to C:\WINDOWS you can't just type: cd c:\windows Vernon Frazee Under 4DOS, the first command will not only change the drive, but it will also switch to that directory! ie. Current is D:\FILES\NEW, I type E:\POINT\IN\, and poof! Current directory is E:\POINT\IN. One of 4DOS' nicer features. This also worked under PC-DOS version 3.1, but you need to issue both commands (%P%\ and cd %P%). Mike Ledoux That's good news. Im use this trick in my INSTALL.BAT, and I wondered if there were any problems with 4DOS or PC-DOS. This is to make sure that the diskette drive is selected in an INSTALL.BAT: if not exist MYFILE %0\ where MYFILE is a specific file supplied on diskette. Horst Schaeffer EDITOR'S NOTE: In response to a request for information as to how to add a directory to the current path via a batch file, I made the following suggestion: Since the current PATH is contained in the environmental variable PATH, you could try using: SET PATH=%%PATH%%;C:\DIR This sets the new PATH (PATH) to contain the current EV PATH (%%PATH%%) plus what you wish to add to the PATH (;C:\DIR). However, the individual making the request expressed concern about whether the current path ended with a ";" and how to detect this possibility to avoid problems. One individual did some experimentation and provided the following insight: (Whether this qualifies as a true MUF I will leave open to discussion) Gary Cooper This may not be neat but I experimented and found out that if there are two semi-colons in a row in your path statement that DOS just ignores this and sets your path anyways. For example it doesn't seem to matter if your path statement/environment variable ends in a semi-colon or not. So you can go ahead and append ;C:\DIR to the end of your path and the path you wish to add will be incorporated. It isn't the perfect solution if you're "picky" but it works (at least in DOS 6.2). If you really have to know if your path ends in ; then experiment with the FIND command. ...with my autoexec.bat I found that if there are two semi-colons in a row... your path is still set as you wish. This means that you don't have to worry whether or not your path ends in a ; but can go ahead and append ;c:\dir to your path. Works with DOS 6.2 anyway. If you are a perfectionist and don't want to see ;; in your new path try using FIND /I to see if it will locate a ; at the end of your path environment variable and then branch in your install.bat file based on the errorlevel returned by FIND. Russ Amiro EDITOR'S NOTE: A common problem using MS-DOS is case sensitivity. Gerry Pareja has demonstrated how PATH can be used to convert to upper case. IE: Begin with the valid commands and the "empty command" then put a "goto :ERROR" on the next line: if %1. == . goto :ERROR if %1 == A goto :A if %1 == B goto :B if %1 == C goto :C goto :ERROR Thus the batch file will go to ":ERROR" if none of the conditions are met. Bruce Wilson You'd still have to worry about upper-casing the input, or check for both A and a, B and b, etc. Here's a built-in upper-case routine (a DOS kludge!): set dummy=%1 :: convert to uppercase: set oldpath=%path% path=%dummy% set dummy=%path% path=%oldpath% set oldpath= Now "dummy" contains an upper-case version of %1, so tests for %1 become tests for %dummy%. Works well. (The explanation: "path=" forces uppercase, while "set path=" retains the original case. Don't ask me why. Ask Microsoft.... ;-) Gerry Pareja =============================================================================== 24) REN or RENAME Here's something that I believe qualifies as a MUF. It works in MS-DOS 5.0 and probably in other versions as well, although I haven't had an opportunity to test any. You can create filenames with embedded spaces from the DOS command line by using the RENAME command with the "?" wildcard. For example, if you have a file named FILE.TST, the command REN FILE.TST FILE?1.TST will produce a file with the name "FILE 1.TST". So far as I know, this feature has no practical use whatever. Gary Smith I tried this under MS-DOS 6.2. When trying to rename WIN4.TXT to WIN?4.TXT, I got WIN44.TXT. To go back, I tried: ren WIN??.TXT WIN4.TXT it worked. Also, with a typo, I found that ren WIN4.TXT to WIN4?.TXT gets a 'duplicate file name' message. Strange. Julian Corey The trick is that the question mark in the target filename must align with an unused position in the source filename. Renaming WIN4.TXT to WIN4?4.TXT works in this manner.