From ts@uwasa.fi Wed Jan 10 02:00:00 2001
Subject: Dostricks file information
Date: Wed, 10 Jan 2001 02:00:00
From: ts@uwasa.fi (Timo Salmi)

Assorted MS-DOS Tricks                           Wed 10-January-2001
======================
                                                 All rights reserved
                               Copyright (c) 1994-2001 by Timo Salmi

....................................................................
Prof. Timo Salmi   Co-moderator of news:comp.archives.msdos.announce
Moderating at ftp:// & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance  ; University of Vaasa
mailto:ts@uwasa.fi <http://www.uwasa.fi/~ts/>  ; FIN-65101,  Finland
Spam foiling in effect.  My email filter autoresponder will return a
required email password to users not yet in the privileges database.
....................................................................

  Ŀ
   This file belongs to TSBAT*.ZIP. Please do not distribute 
   this 1DOSTRIK.TXT file separately! If you see this file   
   distributed alone, please alert the SysAdmin immediately. 
  

You are free to quote brief passages from this file provided you
clearly indicate the source with a proper acknowledgment.

Comments and corrections are solicited. But if you wish to have
individual MS-DOS / batch usage consultation, please rather post
your question to a Usenet newsgroup like news:comp.os.msdos.misc or
news:alt.msdos.batch. It is much more efficient than asking me by
email. I'd like to help, but I am very pressed for time. I prefer to
pick the questions I answer from the Usenet news. Thus I can answer
publicly at one go if I happen to have an answer. Besides,
newsgroups have a number of readers who might know a better or an
alternative answer. Don't be discouraged, though, if you get a reply
like this from me. I am always glad to hear from fellow MS-DOS
users.
--------------------------------------------------------------------

From ts@uwasa.fi Wed Jan 10 02:00:01 2001
Subject: 1DOSTRIK.TXT index
Date: Wed, 10 Jan 2001 02:00:01
From: ts@uwasa.fi (Timo Salmi)

INDEX
=====

D1)  Is it possible to disable dangerous MS-DOS commands?
D2)  When and How to Simulate disk partitioning?
D3)  A config.sys and autoexec.bat example
D4)  Stepping through config.sys and autoexec.bat command by command
D5)  Can I get rid of the annoying "Insert diskette for drive B:"?
D6)  Conditional deleting of files
D7)  Selected Doskey macro examples
D8)  Bypassing or stepping through config.sys and autoexec.bat
D9)  What does "Out of environment space" mean? How do I get more?
D10) How can I delete a file/directory with a space in the name?
--------------------------------------------------------------------

From ts@uwasa.fi Wed Jan 10 02:00:02 2001
Subject: Disabling MS-DOS commands
Date: Wed, 10 Jan 2001 02:00:02
From: ts@uwasa.fi (Timo Salmi)

D1. Is it possible to disable dangerous MS-DOS commands?
========================================================

You may wish to disable certain MS-DOS commands for security reasons
to prevent them from being used either accidentally or deliberately.
If you have a command line editor, like doskey, then the disabling
is rather straightforward.  All you have to do is to create a macro
with the same name as the MS-DOS command. Consider the following
examples. The first example disables the internal MS-DOS date
command so that the date on your system cannot be changed.
  C:\DOS\DOSKEY DATE=rem date has been disabled
The second example disables the format command.
  DOSKEY FORMAT=rem Path to format required
Note that since format is an external command, that is it is a
program on your disk, not a command in your command.com command
interpreter, you can still invoke it by giving the explicit path to
it like
  C:\DOS\FORMAT
In fact, since it will be at path, a drive letter will suffice. Of
course it is very easy to get rid of these redefinitions. In using
doskey, you only have to press alt+F10 to clear the macros.
The critical MS-DOS commands you may wish to consider disabling
include
  FORMAT
  DELTREE

If you use some other command line editor than doskey then the
commands are naturally slightly different.  For example were you to
use CED (ftp://garbo.uwasa.fi/pc/cmdutil/ced10da.zip) the commands
would be
  ced syn date echo date has been disabled
Restoring the date command would be
  ced clear syn date

 A2: A prudent precaution is to move commands such as FORMAT, FDISK
and DELTREE completely off the path to a directory of their own. For
example, the following, very simple FORMATA.BAT batch, which can be
along the path, would see to your immediate needs of formatting
diskettes only. This arrangement would be much safer against
accidents and mischief.
  @echo off
  choice /c:yn /t:n,10 "Start FORMAT A: (10 seconds to answer Y) "
  if errorlevel 2 goto _out
  c:\dos\safety\format a: %1 %2 %3 %4 %5 %6 %7
  :_out
For added protection you can apply
  attrib +h c:\dos\safety
--------------------------------------------------------------------

From ts@uwasa.fi Wed Jan 10 02:00:03 2001
Subject: Simulating disk partitioning
Date: Wed, 10 Jan 2001 02:00:03
From: ts@uwasa.fi (Timo Salmi)

D2. When and How to Simulate disk partitioning?
===============================================

Since I have more than one PC at my disposal, I have noticed that it
is very useful to have some common standard on them including
similar disk names. For example, in MS-DOS I always used to assume
that R: is my ramdisk. Also I usually have my hard disk partitioned
so that I have a fairly fixed usage for C: D: E: and F:. One of the
PCs is an ICL laptop, with a 120Mb disk all on C: with no
partitioning. below is what I have in my autoexec.bat to have the
ram disk reference the way I want and to simulate the disk
partitioning. Note the importance of the order of the substitute
commands because of the double usage of D, since that is where the
ram disk _originally_ resides on my ICL configuration.
  c:\dos\subst r: d:\
  c:\dos\subst d: c:\d
  c:\dos\subst e: c:\e
  c:\dos\subst f: c:\f

WARNING! Do not use the subst command under Windows. Only
consider it if you are running vanilla MS-DOS.

If you have several PCs you may also wish to take a look at the item
"35) A tip for power users. Identifying the individual PC." in
1BATFAQ.TXT.
--------------------------------------------------------------------

From ts@uwasa.fi Wed Jan 10 02:00:04 2001
Subject: Bootfile examples
Date: Wed, 10 Jan 2001 02:00:04
From: ts@uwasa.fi (Timo Salmi)

D3. A config.sys and autoexec.bat example
=========================================

There always is something to learn from looking at the other users'
config.sys and autoexec.bat files. Here are mine from my earlier
office 486 with MS-DOS 5.0. I have added some comments for you.
These are not optimal in any way. Just examples.

DEVICE=C:\DOS\SETVER.EXE
DEVICE=C:\DOS\HIMEM.SYS
DOS=UMB
device=c:\dos\emm386.exe /noems /i=e000-efff /x=d200-d600
dos=high
COUNTRY=032,,C:\DOS\COUNTRY.SYS
FILES=30
rem RamDrive of 7Mb, 128Kb sectorsize, 256 entries, extended memory
devicehigh=c:\dos\ramdrive.sys 7000 128 256 /e
rem ZANSI.SYS is from ftp://garbo.uwasa.fi/pc/screen/zansi12.zip
devicehigh=c:\sys\zansi.sys
rem Define a bigger environment size
shell=c:\command.com /p /e:1024
lastdrive=z

@ECHO OFF
rem Description: My normal MsDos 5.0 boot with Scrollit
rem Note below the trick to identify which of my PCs I am currently using:
set pcid_=karvi
rem Yellow text on black background
echo <ESC>[40;33;1m
PATH C:\DOS;c:\tools;e:\arczip
rem DAILY.BAT is from /pc/ts/tsbat64.zip to run a mini-backup
rem call c:\bat\daily c:\tools\pkzip -u d:\root\root c:\*.*
PROMPT $p$g
rem CHKSUM is from ftp://garbo.uwasa.fi/pc/goldies/chksum16.zip
c:\tools\chksum command.com 49024 io.sys 9850 msdos.sys 5750
loadhigh c:\dos\KEYB SU,,C:\DOS\KEYBOARD.SYS
rem The Command line EDitor is from /pc/goldies/ced.zip
loadhigh c:\tools\ced -B384,128,768,128,128 -Fced.cfg
rem The TSR memory management until is from /pc/memutil/tsrcom35.zip
c:\tools\mark scrollit
rem The screen scrollback buffer is from /pc/screen/scrlit18.zip
loadhigh c:\tools\scrollit /n=myname /k=myid 60
rem The Snipper screen capture is from /pc/goldies/snippr24.zip
loadhigh c:\tools\snipper
rem The cut and paste utility is from /pc/pcmagvol/vol11n07.zip
loadhigh c:\tools\dosclip2
rem The CapsLock fix is from /pc/ts/tstsr23.zip
loadhigh c:\tuki\shftcaps
c:\dos\subst r: j:\
mkdir r:\cmand
copy c:\command.com r:\cmand
c:\dos\attrib +r r:\cmand\command.com
set comspec=r:\cmand\command.com
set temp=r:\cmand
c:\dos\mode con: rate=32 delay=1
rem The clock comparison check is from /pc/ts/tsutil44.zip
c:\tools\dtetimal 2001
r:

Incidentally, if you wish to document what kind of an environment
you have on your PC, take a look at SYSINF.BAT in
 ftp://garbo.uwasa.fi/pc/ts/tsutil44.zip
 Timo's 1st utility set (sysinfo,dirw,dtetimal,timelog,...)

Below is another example of an CONFIG.SYS / AUTOEXEC.BAT pair. This
time they are from my home Pentium desktop.

rem CONGIF.SYS
rem Description: Windows light boot with CD-ROM and JAZ
DEVICE=c:\dos\HIMEM.SYS /testmem:off
device=c:\dos\emm386.exe noems
DOS=HIGH,umb
COUNTRY=032,850,C:\DOS\COUNTRY.SYS
FILES=50
buffers=10
DEVICE=L:\WIN311\IFSHLP.SYS
STACKS=9,256
LASTDRIVE=z
DEVICEhigh=C:\BTCCDROM\BTCCDROM.SYS /D:BTCCD001 /V
devicehigh=c:\dos\ramdrive.sys 16000 256 256 /e
devicehigh=c:\dos\ansi.sys
DEVICEHIGH = C:\IOMEGA\ADVASPI.SYS
DEVICE = C:\IOMEGA\SCSICFG.EXE /V
DEVICEHIGH = C:\IOMEGA\SCSIDRVR.SYS
shell=c:\dos\command.com /p /e:1024


@echo off
rem AUTOEXEC.BAT
rem Description: Windows light boot with CD-ROM and JAZ
set pcid_=wave
set ram=m
echo <ESC>[40;33;1m
L:\WIN311\net start
lh C:\DOS\MSCDEX.EXE /D:BTCCD001 /V /l:z
lh C:\DOS\SMARTDRV.EXE /X 2048 128
PROMPT $p$g
path c:\dos;c:\tools;e:\arczip;L:\WIN311;l:\tcpman;c:\tools_31
SET LMOUSE=C:\MOUSE
lh C:\MOUSE\MOUSE.EXE
lh KEYB SU,,C:\DOS\KEYBOARD.SYS

loadhigh c:\dos\doskey /bufsize=2048
doskey pcopa=pcopy *.* a: /u/v/e/p $*
doskey pcopc=pcopy *.* c: /u/v/e/p $*
doskey pcopd=pcopy *.* d: /u/v/e/p $*
doskey pcope=pcopy *.* e: /u/v/e/p $*
doskey pcopf=pcopy *.* f: /u/v/e/p $*
doskey pcopg=pcopy *.* g: /u/v/e/p $*
doskey pcoph=pcopy *.* h: /u/v/e/p $*
doskey pcopr=pcopy *.* %ram%: /u/v/e/p $*
doskey pcopn=pcopy *.* n: /u/v/e/p $*
doskey pcopt=pcopy *.* t: /u/v/e/p $*
doskey pcopna=pcopy *.* a: /u/v/d:)1/p $*
doskey pcopnc=pcopy *.* c: /u/v/d:)1/p $*
doskey pcopnd=pcopy *.* d: /u/v/d:)1/p $*
doskey pcopne=pcopy *.* e: /u/v/d:)1/p $*
doskey pcopnf=pcopy *.* f: /u/v/d:)1/p $*
doskey pcopng=pcopy *.* g: /u/v/d:)1/p $*
doskey pcopnh=pcopy *.* h: /u/v/d:)1/p $*
doskey pcopnr=pcopy *.* %ram%: /u/v/d:)1/p $*
doskey pcopnn=pcopy *.* n: /u/v/d:)1/p $*
doskey pcopnt=pcopy *.* t: /u/v/d:)1/p $*
doskey format=rem Path to format required
doskey deltree=rem Path to deltree required

c:\dos\mode con: rate=32 delay=1
mkdir %ram%:\cmand
copy c:\command.com %ram%:\cmand
set temp=l:\temp
@SET SCSI_DRIVER = C:\IOMEGA
@SET SCSI_UTILITY = C:\IOMEGA
label %ram%: %pcid_%ram_%ram%
c:\dos\attrib +r %ram%:\cmand\command.com
c:\tools\dtetimal 2001
C:\TOOLS_31\GUEST.EXE

echo Windows light boot with CD-ROM and JAZ
choice /c:yn /t:y,10 Load Windows (or wait 10 seconds)
if errorlevel 2 goto _out
if errorlevel 1 goto _win
if errorlevel 0 goto _out

:_win
call c:\tools\win
:_out
--------------------------------------------------------------------

From ts@uwasa.fi Wed Jan 10 02:00:05 2001
Subject: Tracing boot files
Date: Wed, 10 Jan 2001 02:00:05
From: ts@uwasa.fi (Timo Salmi)

D4. Stepping through config.sys and autoexec.bat command by command
===================================================================

MS-DOS 6.0 introduced the possibility of pausing at each line of
config.sys and even selecting if the line is executed. If you press
F8 when your PC is being booted and displays "Starting MS-DOS...",
then "MS-DOS will prompt you to confirm each CONFIG.SYS command". If
you have an earlier MS-DOS version, you can still put pauses in your
config.sys by utilizing
 6333 Jan 23 1993 ftp://garbo.uwasa.fi/pc/sysutil/pausedev.zip
 pausedev.zip PAUSE for config.sys (with TP source) D.Murdoch

To step through autoexec.bat you can use the following trick
  @echo off
  set debug_=true
  command1
  if "%debug_%" == "true" pause
  command2
  if "%debug_%" == "true" pause
  command3
  set debug_=

If you have MS-DOS 6.0 or later you can use the CHOICE command to
prompt whether you want a command to be executed. If you have an
earlier MS-DOS version you can use "CHOOSE.EXE Ask questions in
batch files" from the ftp://garbo.uwasa.fi/pc/ts/tsutlf16.zip (or
ASK.EXE from ftp://garbo.uwasa.fi/pc/ts/tsbat64.zip). Below is an
outline example
  @echo off
  set debug_=true

  if not "%debug_%" == "true" goto _comm1
  CHOOSE /c:yn /n "Execute command1 [Y/N]? "
  if not errorlevel==3 if errorlevel==2 goto _next2
  :_comm1
  command1

  :_next2
  if not "%debug_%" == "true" goto _comm2
  CHOOSE /c:yn /n "Execute command2 [Y/N]? "
  if not errorlevel==3 if errorlevel==2 goto _next3
  :_comm2
  command2

  :_next3
  (and so on)

  set debug_=
--------------------------------------------------------------------

From ts@uwasa.fi Wed Jan 10 02:00:06 2001
Subject: One floppy drive blues
Date: Wed, 10 Jan 2001 02:00:06
From: ts@uwasa.fi (Timo Salmi)

D5. Can I get rid of the annoying "Insert diskette for drive B:"?
=================================================================

 Q: On my one-floppy-drive PC how can I get rid of the message
"Insert diskette for drive B: and press any key when ready"?

 A: The answer is simple as can be. Put the following command into
your AUTOEXEC.BAT file: "SUBST B: A:\". It makes B: point to the one
floppy drive (A:) you have on your system.
   Don't use the SUBST command if you run your MS-DOS under Windows.
--------------------------------------------------------------------

From ts@uwasa.fi Wed Jan 10 02:00:07 2001
Subject: Conditional del command
Date: Wed, 10 Jan 2001 02:00:07
From: ts@uwasa.fi (Timo Salmi)

D6. Conditional deleting of files
=================================

 This is an improved adaptation of the tip in the PC Computing
Special Issue, 1001 tips, August 1994, pp. 106-232.
 If you have MS-DOS 5+ you can utilize this simple doskey macro to
move files to a trash directory. First ensure that such a directory
exists and if not, mkdir it.
  doskey del=if exist $1 copy $1 r:\trash$Tif not exist $1 echo
  File $1 not found^G$Tif exist $1 del $1 /p
where all the above is on the SAME line.
 You can precede the command with loadhigh to save conventional
memory. I have r: as ramdisk so the trash directory will
automatically be erased when I turn off the computer, or when it
chooses to crash :-).
--------------------------------------------------------------------

From ts@uwasa.fi Wed Jan 10 02:00:08 2001
Subject: Doskey macros
Date: Wed, 10 Jan 2001 02:00:08
From: ts@uwasa.fi (Timo Salmi)

D7. Selected Doskey macro examples
==================================

Here is a collection of my useful Doskey macros. They are reasonably
simple. You'll learn by working them out in detail. Be somewhat
careful in experimenting. Make test files to try then on rather than
running them on your existing files.

a) To go up one directory level.
 doskey up=if exist ..\nul cd ..

b) Move a file to another directory.
 doskey mv=if exist $2\nul copy $1 $2$Tif exist $2\nul del $1 /p

c) Prevent accidental formats.
 doskey format=echo Bugger off^G^G^G
 (Tip: to format, give the full path. Usually c:\dos\format)

d) Touch a file's date/timestamp, that is make it to be now.
 doskey touch=copy $1 + ,,$Tdir $1

e) Search for a file through all drives.
 doskey where=for %f in (c d e f g h) do dir %f:\$1 /s /p /b

f) Show current time without changing it
 doskey showtime=echo.$Btime$Techo.$Bdate

g) Perform a command, skipping a file (wildcards allowed).
 doskey skip=attrib +h $1$T$2 $3 $4 $5 $6 $7 $8 $9$Tattrib -h $1

h) Piping a command with doskey
 doskey mdir=dir *.* $b more

--------------------------------------------------------------------

From ts@uwasa.fi Wed Jan 10 02:00:09 2001
Subject: Function keys and bootup
Date: Wed, 10 Jan 2001 02:00:09
From: ts@uwasa.fi (Timo Salmi)

D8. Bypassing or stepping through config.sys and autoexec.bat
=============================================================

This is standard MS-DOS lore straight out of the manuals, but it is
worth repeating in case your boot process freezes your PC.
   When you have (re)booted your PC wait until you see the message
"Starting MS-DOS...". If you press F5, your CONFIG.SYS and
AUTOEXEC.BAT are bypassed by the boot process. If you press F8 the
boot process steps through your CONFIG.SYS and AUTOEXEC.BAT a
command line at a time and you get to choose which lines to execute
and which not.
   On the other hand, it is possible to disable the bypassing. Set
in your GONFIG.SYS "SWITCHES /K". For more see "HELP SWITCHES".
--------------------------------------------------------------------

From ts@uwasa.fi Wed Jan 10 02:00:10 2001
Subject: Ensuring sufficient environment
Date: Wed, 10 Jan 2001 02:00:10
From: ts@uwasa.fi (Timo Salmi)

D9. What does "Out of environment space" mean? How do I get more?
=================================================================

It means just that. You have run out of space for the environment
variables in your batch. It will (usually) not work correctly then.
By default MS-DOS allocates (only) 256 bytes for the environment
variables. You can alter the environment space to be from 160 to
32768 bytes. Put e.g. the following line into your CONFIG.SYS file
to increase the environment size
  SHELL=C:\DOS\COMMAND.COM /P /E:1024
If you are running MS-DOS in a Windows 3.1x dosbox you may need to
add the following directive to the SYSTEM.INI file
  [NonWindowsApp]
  CommandEnvSize=1024
If you wish to check your environment space consumption, please see
the item "25) How can I test if my batch has sufficient environment
space?" in 1BATFAQ.TXT. '

Gerry Kroll (my compliments) wrote: "Timo, I would change the
example SHELL= line to
    SHELL=C:\DOS\COMMAND.COM C:\DOS /P /E:1024
The second occurrence of "c:\dos" (parameter #2) is used to generate
the COMSPEC environment variable.  Without this entry, COMSPEC
defaults to C:\ thus requiring the PC to have *two* copies of
COMMAND.COM, one in the root directory of the boot drive and the
other in the mentioned directory.
   You might also want to mention that a SHELL line of this format
applies to DOS sessions started from Windows 95 / 98 also.  The
difference is that the "DOS" directory name is changed to the
directory into which Windows 95 / 98 is installed.
   There are a few DOS programs around that still insist on looking
for a copy of COMMAND.COM in the root directory of the boot drive
(ignoring the COMSPEC setting).  I believe SYS is one of these.
FORMAT used to require this (because it called SYS), but I think
this has been fixed."

--------------------------------------------------------------------

From ts@uwasa.fi Wed Jan 10 02:00:11 2001
Subject: Deleting files with spaces
Date: Wed, 10 Jan 2001 02:00:11
From: ts@uwasa.fi (Timo Salmi)

D10. How can I delete a file/directory with a space in the name?
================================================================

First please note. As with the other items in my batch/MS-DOS FAQs
this answer covers up to MS-DOS 6.22. Windows 95/98 long files names
are not covered by this information.

Every now and then users encounter files which they seeming cannot
delete. One common cause is that there is a space or a special
character like ASCII 255 in the file name. The ordinary MS-DOS DEL
command cannot delete such files. One program that can handle file
names with blanks is my "TDEL

Timo's safe recursive delete" from
 ftp://garbo.uwasa.fi/pc/ts/tsutle23.zip
 Timo's 5th utility set (lock keyboard,mailsplit,tdel,cmos,...)
E.g. if you have a file "TEST FLE.TXT" you can try to delete it e.g.
using "TDEL TEST*". Likewise, if you have a directory with spaces in
the name, you can use "DELEDIR.EXE Generalized delete directory"
from
 ftp://garbo.uwasa.fi/pc/ts/tsutlf16.zip
 Timo's 6th utility set (advdate,choose,deledir,strings,strmemo,)

A related question is how can one create for test purposes a file
with spaces in the file name. Here goes:
  @echo off
  >> tmp$$$.bas echo OPEN "TEST FLE.TXT" FOR OUTPUT AS #1
  >> tmp$$$.bas echo PRINT #1, "TEST FLE.TXT"
  >> tmp$$$.bas echo CLOSE #1
  >> tmp$$$.bas echo SYSTEM
  qbasic /run tmp$$$.bas
  del tmp$$$.bas

