home *** CD-ROM | disk | FTP | other *** search
/ HaCKeRz Kr0nlcKLeZ 3 / HaCKeRz_KrOnIcKLeZ.iso / chibacity / dosundoc.txt < prev    next >
Encoding:
Text File  |  1996-04-23  |  17.6 KB  |  469 lines

  1. Collection of undocumented and obscure features in various MS-DOS versions.
  2. ---------------------------------------------------------------------------
  3.  
  4. Contents:
  5.  
  6. - TRUENAME
  7. - FDISK /STATUS
  8. - FDISK /MBR
  9. - SHELL=C:\COMMAND.COM /P /F
  10. - COMMAND /F
  11. - COMMAND /P
  12. - COMMAND /D
  13. - VER /R
  14. - ECHO OFF and ECHO ON
  15. - FORMAT /AUTOTEST
  16. - FORMAT /BACKUP
  17. - FORMAT /SELECT
  18. - FORMAT /SELECT /U
  19. - FORMAT /H
  20. - IF EXIST <dirname>\NUL <command> and IF EXIST EMMXXXX0 <command>
  21. - Using ATTRIB to hide directories
  22. - SWITCHES=/W
  23. - FOR %%V IN (/SOMETHING)
  24. - DIR,
  25. - COPY. A:
  26. - DOS?=HIGH
  27. - INSTALLHIGH
  28. - Using : for batch file comments
  29. - REM in lines with pipes or redirection
  30. - Delimiter character
  31.  
  32. ===========================================================================
  33.  TRUENAME
  34.  --------
  35.  
  36. Internal DOS 5.0 command.  Canonicalize a filename or path (using DOS
  37. interrupt 21h, function 60) prints the actual directory.
  38.  
  39.      Syntax:
  40.  
  41.      TRUENAME filename   - Prints the complete path to file.
  42.      TRUENAME directory  - Prints the complete path to directory.
  43.  
  44. Note:  If the path is in a network, it starts with a \\machine-name.
  45.  
  46. TRUENAME is analogous to the UNIX "whence" command.  It returns the real
  47. fully-qualified path name for a command.
  48.  
  49. TRUENAME is useful in networks, where a physical drive may be mapped to a
  50. logical volume, and the user needs to know the physical location of the
  51. file.  It ignores the DOS SUBST and JOIN commands, or network MAPped
  52. drives.
  53.  
  54. TRUENAME is an undocumented MS-DOS feature, but it is documented in JP
  55. Software's 4DOS software (COMMAND.COM replacement) as follows:
  56.  
  57.      Syntax:
  58.  
  59.      TRUENAME [d:][path]filename
  60.  
  61.      Purpose:
  62.  
  63.      Returns a fully qualified filename.
  64.  
  65.      Comments:
  66.  
  67.      TRUENAME will see "through" JOIN and SUBST commands, and
  68.      requires MS-DOS 3.0 or above.
  69.  
  70.      Example:
  71.  
  72.      The following command uses TRUENAME to get the true pathname
  73.      for a file:
  74.  
  75.      c:\>subst d: c:\util\test
  76.      c:\>truename d:\test.exe
  77.  
  78.      c:\util\test\test.exe
  79.  
  80. TRUENAME : will reveal the full name drive and path of the filename.  If
  81. you specify a wildcard (*) in the filename, it will expand the filename to
  82. use question marks instead.  If the path includes the ..\ sequence,
  83. TRUENAME will examine the directory structure and calculate the path.
  84.  
  85. Stranger still, the line:
  86.  
  87.      TRUENAME \CRONK\FLIBBET\..\ART
  88.  
  89. ...produces the response:
  90.  
  91.      C:\CRONK\ART
  92.  
  93. ...even if the directories \CRONK\FLIBBET and the file ART don't exist!
  94. Don't expect this command to work well across networks.  After all, this is
  95. still undocumented in MS-DOS for a reason!
  96.  
  97. ===========================================================================
  98.  FDISK /STATUS
  99.  -------------
  100.  
  101. Prints a screen just like using option 4 of FDISK, "Partition information",
  102. but includes extended partition information.  Nice if you want to get an
  103. overview without fear of pressing the wrong keys.
  104.  
  105. Doesn't work in DOS 3.30.
  106.  
  107. ===========================================================================
  108.  FDISK /MBR
  109.  ----------
  110.  
  111. MS-DOS 5.0 FDISK has an undocumented parameter, /MBR, that causes it to
  112. write the master boot record to the hard disk without altering the
  113. partition table information.  While this feature is not documented, it can
  114. be told to customers on a need-to-know basis.
  115.  
  116. Warning:  Writing the master boot record to the hard disk in this manner
  117. can make certain hard disks partitioned with SpeedStor unusable.  It can
  118. also cause problems for some dual-boot programs, or for disks with more
  119. than 4 partitions.  Specific information is below.
  120.  
  121. What is the MBR?
  122.  
  123. At the end of the ROM BIOS bootstrap routine, the BIOS will read and
  124. execute the first physical sector of the first floppy or hard drive on the
  125. system. This first sector of the hard disk is called the master boot
  126. record, or sometimes the partition table or master boot block. At the
  127. beginning of this sector of the hard disk is a small program. At the end of
  128. this sector is where the partition information, or partition table, is
  129. stored. This program uses the partition information to determine which
  130. partition is bootable (usually the first primary DOS partition) and
  131. attempts to boot from it.
  132.  
  133. This program is what is written to the disk by FDISK /MBR and is usually
  134. called the master boot record.  During normal operation, FDISK only writes
  135. this program to the disk if there is no master boot record.
  136.  
  137. Why is the MBR changed during Setup?
  138.  
  139. During installation of Microsoft MS-DOS 5 Upgrade, Setup will replace the
  140. master boot record on the hard disk with code to display the message:
  141.  
  142.         The MS-DOS 5.0 Setup was not completed.
  143.         Insert the UNINSTALL #1 diskette in drive A.
  144.         Press the ENTER key to continue.
  145.  
  146. This message should be erased and the master boot code rewritten before
  147. Setup is completed. If a problem occurs during Setup and you return to the
  148. previous MS-DOS, UNINSTAL should also remove this message. However, should
  149. Setup or UNINSTAL fail to remove this message, or should the master boot
  150. record become corrupted, a new master boot record can be written to the
  151. disk using the following command:
  152.  
  153.          C:\>fdisk /mbr
  154.  
  155.      WARNINGS:
  156.  
  157.      This option should not be used if:
  158.  
  159.         - the disk was partitioned using Storage Dimensions'
  160.           SpeedStor utility with its /Bootall option
  161.         - more than 4 partitions exist
  162.         - certain dual-boot programs are in use
  163.  
  164. Storage Dimensions' SpeedStor utility using the /Bootall option redefines
  165. the drive's physical parameters (cylinder, head, sector).  /BOOTALL stores
  166. information on how the drive has been changed in an area of the master boot
  167. record that MS-DOS does not use. FDISK /MBR will erase that information,
  168. making the disk unusable.
  169.  
  170. Some older OEM versions of MS-DOS and some third-party partitioning
  171. utilities can create more than 4 partitions.  Additional partition
  172. information is commonly stored information on partitions in an area that
  173. FDISK /MBR will overwrite.
  174.  
  175. Some dual-boot programs have a special MBR that asks the user which
  176. operating system they want on bootup.  FDISK /MBR erases this program.
  177. Dual-boot systems that boot whichever partition is marked Active are not
  178. affected by FDISK /MBR.
  179.  
  180. If you have a Boot Sector Virus, just boot from a known "clean" floppy disk
  181. that's write protected and which has FDISK on it, and run FDISK /MBR.
  182.  
  183. ===========================================================================
  184.  SHELL=C:\COMMAND.COM /P /F
  185.  --------------------------
  186.  
  187. The /F in the CONFIG.SYS SHELL= statement forces a "Fail" response to all
  188. "Abort, Retry, Fail" prompts issued by the DOS critical error handler.
  189.  
  190. ===========================================================================
  191.  COMMAND /F
  192.  ----------
  193.  
  194. Entered on the command line, COMMAND /F makes all those annoying "Abort,
  195. Retry, Ignore, Fail" disk error messages default to "Fail" from then on
  196. until rebooting.
  197.  
  198. ===========================================================================
  199.  COMMAND /P
  200.  ----------
  201.  
  202. For DOS 3.30 (not checked with other versions):  Docs say that this doesn't
  203. allow you to exit back to the previous shell, but /P also forces
  204. AUTOEXEC.BAT to be run on secondary shells.
  205.  
  206. ===========================================================================
  207.  COMMAND /D
  208.  ----------
  209.  
  210. When used with a primary shell, or secondary with /P, prevents execution of
  211. AUTOEXEC.BAT.
  212.  
  213. ===========================================================================
  214.  VER /R
  215.  ------
  216.  
  217. Yields extended information about the DOS version:
  218.  
  219.      MS-DOS Version 5.00
  220.      Revision A
  221.      DOS is in HMA
  222.  
  223. Doesn't work with DOS 3.30.  VER /R is a documented feature of JP
  224. Software's 4DOS.
  225.  
  226. ===========================================================================
  227.  ECHO OFF and ECHO ON
  228.  --------------------
  229.  
  230. Entering ECHO OFF from the command line erases the prompt and leaves just a
  231. cursor on the screen.  ECHO ON from the command line restores the prompt.
  232. This works with all version of DOS.
  233.  
  234. One of the most frequently asked questions is "How do I ECHO a blank line
  235. in a batch file?"  The most common answer is to use ECHO directly followed
  236. by a period:  ECHO. like so.  However, just about any "white space"
  237. character will work, as well as any "delimiter".  The following
  238. alternatives can be used:  ECHO.  ECHO"  ECHO,  ECHO:  ECHO;  ECHO[  ECHO]
  239. etc.  Apparently it's just the way that the command handles the delimiter
  240. and has been available from way back!  Microsoft just began mentioning it
  241. in the documentation recently, though, and their examples use a period.
  242.  
  243. ===========================================================================
  244.  FORMAT /AUTOTEST
  245.  ----------------
  246.  
  247. The autotest parameter will allow FORMAT to proceed, checking the existing
  248. format of the disk (unless the /U parameter with DOS 5 or 6 is also
  249. present), and proceeding with the format.
  250.  
  251. All this will take place with no delay and no waiting for user input.  It
  252. will also end without pausing.  It will not ask for a volume label or
  253. whether to format another diskette.
  254.  
  255. WARNING!  This procedure will also work on hard drives!  Be very cautious
  256. if you plan to use this feature!
  257.  
  258. ===========================================================================
  259.  FORMAT /BACKUP
  260.  --------------
  261.  
  262. This works exactly like /AUTOTEST, but it does ask for a volume label.
  263.  
  264. ===========================================================================
  265.  FORMAT /SELECT
  266.  --------------
  267.  
  268. This is like the DOS MIRROR command... For safety-fanatics only.
  269.  
  270. ===========================================================================
  271.  FORMAT /SELECT /U
  272.  -----------------
  273.  
  274. Just makes a disk unreadable.  Guess it could be handy?
  275.  
  276. ===========================================================================
  277.  FORMAT /H
  278.  ---------
  279.  
  280. In DOS 3.30 (not tested with other versions), FORMAT /H will cause the
  281. format to begin immediately after pressing Y in response to "Format
  282. another", rather than displaying "Place disk to be formatted in drive x:
  283. and press Enter" on a second and subsequent disks.
  284.  
  285. In DOS 5.0, FORMAT reports "invalid switch".
  286.  
  287. ===========================================================================
  288.  IF EXIST <dirname>\NUL <command> and IF EXIST EMMXXXX0 <command>
  289.  ----------------------------------------------------------------
  290.  
  291. This is a handy quirk of DOS.  Installable drivers are seen as files in all
  292. directories.  You can use the if exist test to either test for the
  293. existence of a directory, with "if exist <dirname>\nul", which fails if the
  294. directory does not exist because the nul device is not found; or to test
  295. whether any driver is loaded, such as the DOS 5 or 6 EMM386 memory manager.
  296.  
  297. Caveats:  For testing NUL, you need to know the name of the directory or
  298. the driver whose existence you are testing, and this is MS-DOS specific --
  299. it doesn't work on network drives, and may not work under DR-DOS.
  300.  
  301. Where did you learn the "EMMXXXX0" name from?  Instead of typing MEM /C,
  302. type MEM /D for the "debug" listing.
  303.  
  304. The only trouble is EXISTS returns true for COM3/4 and LPT2/3 even if the
  305. hardware does not exist.
  306.  
  307. ===========================================================================
  308.  Using ATTRIB to hide directories
  309.  --------------------------------
  310.  
  311. The DOS 5.0 and 6.0 ATTRIB command can do the same thing for directories as
  312. it can for files:  ATTRIB +H <dirname>  will hide the named directory.
  313.  
  314. ===========================================================================
  315.  SWITCHES=/W
  316.  -----------
  317.  
  318. Enables you to have the Windows 3.0 WINA20.386 file anywhere on your boot
  319. drive.  Without this you have to have it in the root directory.
  320.  
  321. This should not be used with Windows 3.1, since it appears to waste around
  322. 120K of UMBs.
  323.  
  324. ===========================================================================
  325.  FOR %%V IN (/SOMETHING)
  326.  -----------------------
  327.  
  328. How can a batch file (without 4DOS) determine from which drive it has been
  329. started?
  330.  
  331.       Example:  C:\>a:test.bat
  332.  
  333. Now my batch should be able to find out that it is located on drive A: (not
  334. the path, only the drive!).
  335.  
  336. In a batch file, the variable %0 contains the name of the batch file as it
  337. was typed at the command line.  If you run the batch file as A:TEST.BAT, %0
  338. will be "A:TEST.BAT".  If you have the directory on your path, and simply
  339. type TEST, then %0 will be "TEST".  The drive, path, and extension will
  340. only appear in %0 if you enter them in the command used to call the batch
  341. file (either typed at the command line, or called from another batch file).
  342. So, you must specify the drive as part of the batch filename for this to
  343. work.
  344.  
  345. To extract the drive only from %0, use the undocumented FOR %%V in
  346. /SOMETHING command:
  347.  
  348.      set drive=
  349.      for %%v in (/%0) do call test2 %%v
  350.      echo Calling drive is %drive%
  351.  
  352. ...where TEST2.BAT is:
  353.  
  354.      if not '%drive%'=='' set drive=%1:
  355.  
  356. FOR %%V IN (/SOMETHING) DO WHATEVER will do WHATEVER twice -- the first
  357. time with %%V set to the first character in SOMETHING ("S"), the second
  358. time with all the remaining characters in SOMETHING ("OMETHING").  If
  359. SOMETHING is only a single character, WHATEVER will only be called once,
  360. with that character in %%V.  If the single character is a wildcard (? or *)
  361. that wild card will not be expanded to a set of filenames.  (The main
  362. purpose of this feature is apparently to allow inclusion of the literal
  363. characters "?" and "*" without them being expanded.)
  364.  
  365. This works in DOS 3.30 and later.
  366.  
  367. ===========================================================================
  368.  DIR,
  369.  ----
  370.  
  371. Using a comma immediately after DIR shows ALL files, including the HIDDEN
  372. ones.
  373.  
  374. This appears only to work with DOS 5.0 and 6.0.  With 3.30, it doesn't
  375. display either IO.SYS, MSDOS.SYS (both with S, H and R attribs) or a test
  376. file with A and H attribs.
  377.  
  378. With DOS 5.0, it displayed a test file with H and A, but would not display
  379. IO.SYS or MSDOS.SYS with S, H and R.  This isn't surprising actually, since
  380. S alone (without H) will prevent inclusion of a file in a normal DIR.
  381.  
  382. Not tested with DOS 4.x.  Not supported by JP Software's 4DOS.
  383.  
  384. ===========================================================================
  385.  COPY. A:
  386.  --------
  387.  
  388. The use of a period IMMEDIATELY after some DOS statements will work just
  389. like *.*
  390.  
  391.      Examples:  DEL.      (erase all files in current directory)
  392.                 COPY. A:  (copy all files in current directory to A:)
  393.  
  394. There may be more statements with which it works.
  395.  
  396. This is actually a documented although obscure feature, though the ability
  397. to use the period with COPY is not documented.  What is documented is the
  398. fact that "." and ".." can be used to represent the current and parent
  399. directories respectively, and these will work with many applications which
  400. can handle directory names as arguments.  In this case the "." could also
  401. be viewed as a replacement for "*.*"
  402.  
  403. ===========================================================================
  404.  DOS?=HIGH
  405.  ---------
  406.  
  407. DOS?=HIGH in CONFIG.SYS with DOS 6.0 will prompt you whether to load the
  408. DOS kernel high (into the HMA) or not.
  409.  
  410. ===========================================================================
  411.  INSTALLHIGH
  412.  -----------
  413.  
  414. In DOS 6.0, there is an undocumented CONFIG.SYS command called INSTALLHIGH=
  415. which works just like INSTALL= but loads the TSR high (into upper memory).
  416.  
  417. The only drawback to this is that MemMaker will not touch INSTALLHIGH lines
  418. during the optimizing process.  It just takes it as it is currently.  But
  419. then again, INSTALL= is ignored too.  All in all, INSTALL and INSTALLHIGH
  420. really are commands to set up manually by the user, and are not really
  421. recommended for normal use.  Load TSRs at the beginning of AUTOEXEC.BAT
  422. (and using LOADHIGH if desired).
  423.  
  424.        Example:
  425.  
  426.        DOS=HIGH,UMB
  427.        DEVICE=C:\DOS\HIMEM.SYS
  428.        DEVICE=C:\DOS\EMM386.EXE NOEMS
  429.        INSTALLHIGH=C:\DOS\SHARE.EXE
  430.  
  431. ===========================================================================
  432.  Using : for batch file comments
  433.  -------------------------------
  434.  
  435. DOS uses a leading : to indicate a label in a batch file.  If the next
  436. character following the : is a space or other non-alphanumeric character,
  437. then DOS will decide it's an invalid label and skip to the next line,
  438. performing no further action.  Faster batch file processing is achieved
  439. using this method for comments instead of REM commands.
  440.  
  441. ===========================================================================
  442.  REM in lines with pipes or redirection
  443.  --------------------------------------
  444.  
  445. For example:  REM echo y | del *.*
  446.  
  447. Problems are encountered when trying to REM out an "echo y | del *.*" line
  448. in a batch file.  The problem appears to only occur if there is a pipe or
  449. redirection in the REMed out line, which shows that DOS first reads the
  450. entire line and processes pipes and redirections first, and then goes back
  451. to find out what to do with them in the line.  It's actually doing what it
  452. thinks you've told it:  Piping the output of REM to DEL.  Since REM has no
  453. output, DEL hangs, waiting for the answer to its question.
  454.  
  455. ===========================================================================
  456.  Delimiter character
  457.  -------------------
  458.  
  459. Prior to DOS 5.0, there was an undocumented DOS function that would allow
  460. you to set the DOS option delimiter character to something else, like a
  461. dash (-).  Once you did this, you could use either \ or / in PATH
  462. specifications.
  463.  
  464. DOS 5.0 removed the function to set the option delimiter, but retained the
  465. function to query what it currently is.
  466.  
  467. (Unfortunately, no further details were provided in this file, so not sure
  468. if the delimiter character can still be changed somehow.)
  469.