“DOS is dead, long live the command line “

advertisement
“DOS is dead, (long live
the command line)“
• Source for most of this material:
– http://commandwindows.com
DOS is Dead
• There is a common misconception that the
command prompt in Windows XP is the
same as DOS
• Even Microsoft itself isn't always careful
about the distinction
• There are some superficial resemblances
• However, all remnants of DOS are totally
gone from the Windows XP kernel (there
is a DOS emulator to run legacy apps)
File System Hierarchy
C:
\
Windows
System32
Drivers
Program Files
System
Photoshop
Temp
Adobe
Acrobat
Elements
Pagemaker
C:
\
Windows
System32
Drivers
Program Files
System
Photoshop
Temp
Adobe
Acrobat
Elements
Absolute Path to here?
C:\windows\system32\drivers
Pagemaker
C:
\
Windows
System32
Drivers
Program Files
System
Photoshop
Temp
Adobe
Acrobat
Relative Path from Windows to Drivers?
System32\drivers
Elements
Pagemaker
C:
\
Windows
System32
Drivers
Program Files
System
Photoshop
Temp
Adobe
Acrobat
Relative path from system to drivers?
../system32/drivers
Elements
Pagemaker
Internal Commands
assoc
dir
move
set
break
echo
path
setlocal
call
endlocal
pause
shift
cd
exit
popd
start
cls
for
prompt
time
color
ftype
pushd
title
copy
goto
rd
type
date
if
rem
verify
del
md
ren
volume
Common Usage
Command [arguments]
Command [switches] [path to file or folder]
Command [switches] [path] [path]
Common Usage
Examples:
dir
dir /w
dir /w c:\windows
dir /w /p ..
Common Usage
Examples:
copy mydoc.doc c:\files
move c:\docs\* c:\backups
rename *.txt *.doc
Symbols used with commands
Symbol
Function
Example
>
Sends output to a named file. If file does not exist, it
creates one. Overwrites existing file
command > somefile
>>
Appends output to contents of a named file or
creates a file if none exists
command >> somefile
<
Uses contents of a named file as input to a
command
command < somefile
¦
Sends ("pipes") the output of command1 to the
input of command2
command1 ¦ command2
&
Used to combine two commands. Executes
command1 and then command2
command1 & command2
&&
A conditional combination. Executes command2 if
command1 completes successfully
command1 && command2
¦¦
Command2 executes only if command1 does not
complete successfully.
command1 ¦¦ command2
@
Used in batch files at the beginning of a line to turn
off the display of commands
@echo off
Extended Usage
Examples:
dir c:\windows > windowsDirectoryList.txt
dir | more
echo. | date
Del *.* < y.txt
Environmental Variables
• %username%
• %systemroot%
• SET command
• My Computer.Properties>Advanced.Environmental Variables
Exercises
\
C:
Windows
System32
Drivers
Program Files
System
Photoshop
Temp
Adobe
Acrobat
Elements
Pagemaker
• What’s the absolute path of Temp?
• What’s the relative path from Temp to \ ?
• What’s the relative path from Pagemaker
to Drivers?
Exercises
C
:
\
Windows
System32
Drivers
Program Files
System
Photoshop
Temp
Adobe
Acrobat
Elements
Pagemaker
• On a floppy, create this directory structure using
the command line.
• Create a .txt file in the pagemaker directory
• Copy and rename that file to the elements
directory using only one command
• Write a batch script that will display the contents
of A:\, and write those contents (the listing) to a
file called C:\acontents.txt, and then attempt to
format the floppy
Other resources
• http://www.microsoft.com/resources/docu
mentation/windows/xp/all/proddocs/enus/batch.mspx?mfr=true
Download