DOS-COMMANDS
What if a Windows system file is damaged?
What if a virus damaged such a file? You can rescue your PC, in
DOS. Here we go...for a general explanation of Dos-commands.
You'll notice that some commands are quite powerful, and can
delete data on your HDD. Don't just type every command you see
here, if you don't know what you're doing.
General rule:
1. Everything you do has a result in the
*current* directory (the one you are in at the moment you type
the command). Some commands may execute on the whole disk (debug,
deltree, scandisk, defrag, format, and fdisk).
2. To start an executable file from the DOS
command-line (executable = everything with extention
".bat" ; ".com" ; ".exe"), just
type the name you see before the extention. To start up the file
"setup.exe" from floppy drive a:, you can type
"a:\setup (Enter)" or first a: (Enter) and
then setup (Enter).
Basics:
- a: - go to drive a: (floppy).
- c: - go to drive c: (hard drive).
- cd\ - go to the root-direcory (Change
Directory).
- dir - show files and subdirectories (of course:
in the current directory).
- cd windows - go to the directory, named
"windows".
- dir /p - show files / subdirs, but screen after
screen.
- dir *.dll - show all files with extention
".dll".
- dir *.dll
|more - same, but
screen by screen.
- cd.. - one step back in de directory structure
(from c:\windows to c:\).
- md test - make a directory, named "test".
Make Directory (name).
- cd test - go in this directory (Change Directory).
- copy c:\*.* - copy everything from c:\(root) over here
(here is now "c:\test" - assuming you type the
commands in the sequence of this text).
- copy
a:\setup.exe c:\test -
copy the file "setup.exe" from floppy to HDD,
directory c:\test.
- ren one.bat
two.bat - rename the
file "one.bat" to "two.bat" (if
"one.bat" exists).
- del *.bat - delete all files with ext.
".bat" (only do this in c:\test - dont do
this in "c:\"!).
- del config.* - delete all files with name config (any
ext.) (only in "c:\test"!).
- del msdos.sys - delete the file msdos.sys (! only do this
in c:\test!).
- del *.* - delete everything (only in c:\test,
dont do this in c:\!).
- cd.. - back to c:\ (root) - in fact, one step
back in the directory structure.
- rd test - remove the directory "test"
(there still can be hidden files in it, so this may not
work - see the attrib options further on).
- dir /? - show help and command line options for
the command "dir".
- prompt /? - same for the prompt-command (try this on
all commands - " /?" right behind it).
Advanced...
- attrib *.*
-h-r-s-a - change all
file attributes - so that you can see / remove / change
them all (hidden, read-only, system, archive).
- attrib *.*
+h+r - hide all files,
and set them all "read-only".
- attrib io.sys
-h-r-s-a - allows us
to see and change "io.sys" <note: dont
change it, unless you have a good boot disk ;-) >.
- time - show system clock, possibly change the
time.
- date - same for the date.
- find /n
"CTTY" c:\command.com - find the word CTTY in the file
"command.com".
- prompt $p$g - show current drive and directory.
- prompt $p$g
Type Exit to quit. . .
- same, but with this text...
- path - show in which directorys the system looks
for a file if it cant be found in the current
directory.
- path=c:\tools;%path% - add the directory c:\tools to
the path.
- deltree *.* - delete all files, including all
subdirectories and files in the subdirectories
(Dont do this in c:\).
- deltree /y *.* - same, but without asking comfirmation for
each file.
- deltree /y *.*
>nul - same, but
the user cant see that files are being deleted.
- label - see/change the name of the drive..
- fdisk - show partitions of a drive (Dont
change partitions if you still need files on that
drive!).
- format a: - format a floppy for Dos.
- format c: - format HDD (or partition) for Dos.
(!Don't do this if you need data on that disk!)
Work with files
(overwrite, create, input, and output redirection....
- dir
>a:\test.txt - show
files and subdirectories, and redirect the output to a
file "test.txt" on floppy. The screen output
has been redirected to the file by the ">"
sign - the >- sign means: "redirect
output to").
- dir >prn - send the list of files and subdirectories
to the printer.
- type test.txt - show the file "test.txt" on the
screen. This command has the same result as
"copy test.txt con" (copy <filename> to
console).
- notepad
test.txt - in windows
this also works - "start test.txt with
notepad.exe".
- echo whatever
>>test.txt - add
the word "whatever" in the file
"test.txt" (append).
- echo Killroy
was here >test.txt -
The words "Killroy was here" are written to
test.txt, but the previous contents of the file is
overwritten because we only used one ">"-
sign.
- type test.txt - show again.
- echo bigdisk
>a.txt - make a
file "a.txt" with only the word
"bigdisk" in it.
- label
<a.txt - rename the
disk to the word in "a.txt" (< : get input
from).
- echo bigdisk
|label - the current
disk will be renamed in one command to
"bigdisk" (the | - sign (or pipe)
gives the output of a program (or command) to another
program).
- echo y |format
c: - the HDD will be
formatted unconditionally (no confirmation (Y/N) is asked
because the "Y" is given to the format command
by the | - sign. Don't test this on your PC if you need
data on it - it *does* work. Of course, for a German or
Dutch Dos-version you need to type "echo j |format
c:" or if the OS language is French: "echo o
|format c:" (Oui, oui, c'est ça).
- echo y |format
c: >nul - the same
but the user doesnt see whats happening.
- time
>>test.txt - hit
the Enter key twice in order not to change
the time, or,
- echo. |time
>>test.txt - in
this case, just hit enter once.
("echo." - notice the . - gives the
Enter).
- type test.txt - *sigh* do I still have to explain this?
....
> redirects output to (file or device after
the >- sign) Any already existing file with the same name is overwritten.
>> appends to a file, if the file doesnt
exist, it is created.
< gets input from (file or device). Devices
are nul, clock$, aux, con, prn, com1 - com4, lpt1...
- copy clock$
test.txt - If you
leave this command running in the background (interrupt
with Ctrl + C) youll fill up the HDD. Clocktics are
written to file, 1 Mbyte / minute on a P75. Useless
command otherwise, but hey, we're just testing...
- netstat -an 30
>>log.txt - log
all network addresses and ports, on my PC and on the
remote PC, do this every 30 seconds -in a file
"log.txt". Try to get on my HDD via the
internet or network without me seeing you (in the log
file). Interrupt with Ctrl + C.
- copy test.txt
lpt1 - send the file
test.txt to the printer (if the printer is
connected to LPT1).
- echo g=ffff:0
|debug - cold reboot
your PC. Start debug, and execute the instructions. It's
a zero after ffff: , not the letter "o". Also:
- echo o 64,fe
|debug (O - out, not 0
(zero)). Confusing, huh?
- choice /cy /n
/ty,9 >nul - Wait 9
seconds. Start the program "choice", dont
show output on the screen, choose y after 9
seconds, continue.
- echo rem you
dont see this on your screen >nul
>>c:\autoexec.bat
- append the line rem etc. ... to
c:\autoexec.bat, dont show execution on the screen.
- ctty nul - If you execute this command in a complete
dos-exit, the PC will freeze. Input and output
arent from the keyboard and to the screen, but from
and to the nul device.
- ctty con - In and output normal again (can only be
given from within a bat file, if after ctty
nul).
knip@bigfoot.com
Back
to main page