Beruflich Dokumente
Kultur Dokumente
In Windows7
C:\> cd WINDOWS
C:\>WINDOWS> CD SYSTEM32
C:\> WINDOWS> SYSTEM32 > dir
ATTRIB
Change or view the attributes of one or more files.
Stored in ATTRIB.EXE file which is needed for its
execution.
Syntax:
ATTRIB [+R|-R] [+A|-A] [+S|-S] [+H|-H][drive:][path][filename] [/S [/D]]
Options:
To add an attribute attach a '+' in front of it.
To remove an attribute attach a '-' in front of it
Attributes include
• R - Read-only
• A - Archive
• S - System
• H - Hidden
• /D - Process folders as well.
• /S - Process matching files in the current folder and all subfolders.
ATTRIB: EXAMPLES
C:\>attrib
Shows the current attributes of all the files
present at C drive.
C:\>attrib abc +H
hides the abc file.
C:\>test +H +R
hides and make the test file read only.
LABEL
Requires LABEL.EXE file for its execution.
Label is used to view or change the label of the
computer disk drives.
Syntax:
LABEL [drive:][label]
Example:
C:\>label a: mydisk
This would label the disk currently in the drive to
"mydisk“.
BACKUP
External command that requires BACKUP.EXE
for executing this command.
Enables users to backup their data on their
computer.
Syntax:
BACKUP [Source:\Path\Filename] [Target:] [/s]
[/m] [/a] [/d:date] [/t:time] [/f:size]
[/L:LogDrive:\Path\Log]
BACKUP OPTIONS
/A Does not erase the files on the target disk .
/F:(size) Formats the target disk (if it is not already formatted).
/L Makes an entry in the backup log in the file you specify here.
/M Only backs up files that have been modified since the last time the
BACKUP command was used.
/S Causes files in the specified directory and all subdirectories below the
specified directory to be backed up.
/D:(date) Backs up files only if they have been created or modified on or after the
date you enter.
/T:(time) Backs up files only if they have been created or modified on or after the
time you enter.
BACKUP: Examples
C:\>backup C:\TC F:/S
Copies all the files with all subdirectories of the
TC directory to drive F.
C:\>backup c:\letters\sale*.* a:
All files in the drive C LETTERS directory that
begin with SALE and with any filename
extension are backed up onto the disk in drive A.
CHKDSK
C:\>chkdsk
checks the current drive.
C:\>chkdsk a:
checks the drive a.
FORMAT
Requires an external file FORMAT.COM.
Used to make a disk usable for OS by dividing the
disk into magnetic tracks and sectors.
Syntax:
FORMAT drive:/switches
FORMAT Options
/V[:label] Specifies the volume label.
/Q Performs a quick format.
/F:size Specifies the size of the floppy disk to format (such as 160,
180, 320, 360, 720, 1.2, 1.44).
/B Allocates space on the formatted disk for system files.
/S Copies system files to the formatted disk.
/T:tracks Specifies the number of tracks per disk side.
/N:sectors Specifies the number of sectors per track.
/1 Formats a single side of a floppy disk.
/8 Formats eight sectors per track.
/C Tests clusters that are currently marked "bad."
FORMAT: Examples
C:\>format A:
formats a disk A.
C:\>format A:/3
formats 31/2 inch floppy disk.
MOVE
Executed when a file MOVE.EXE is loaded in
RAM.
Used to move one or more files.
Analogous to cut and paste.
Syntax:
MOVE <source> <destination>
MOVE Options
C:\>deltree c:\fake010
Deletes the fake010 directory and everything
in it.
C:\>deltree D:\test\*.*
Deletes all the files in test directory present
on drive D.
FIND
C:\>dir|find def
Displays whether the file def is there in the current path or not.
RESTORE
Used to restore files from disks made using the
BACKUP command.
Syntax:
RESTORE sourcedrive: targetdrive: [path][/switches]
Restore Options
/P The program prompts you before it restores files that have been
changed since the last backup or files that are marked read-only.
/S Backed up files from both the specified source directory and from
subdirectories within that directory are transferred to the target
path designation
/B:mm-dd-yy Only restores files that were modified on or BEFORE the date you
enter.
/A :mm-dd-yy Only restores files that were modified on or AFTER the date you
enter.
/E Only restores files that were modified at or EARLIER than the time
you enter.
/L Only restores files that were modified at or LATER than the given
time.
/M Only restores files that have been modified since the last backup.
/N Only restores files that no longer exist on the destination disk.
/D Displays a list of the files on the backup disk that match the names
specified in filename without restoring any files
RESTORE: Example
C:\>restore A: C:
restores files from the backup disk in drive A:
that originally resided on the currently logged
subdirectory.
SORT
Sorts input and sends it to the screen or to a file.
Syntax
SORT [/R][/+n] <filename>
Options
/checkonly Use this option if you want to check a drive for errors
without repairing the damage.
DISKCOPY
Requires an external file DISKCOPY.EXE for its
execution.
Used to copy all the files as well as directories
from one disk to another on a track by track basis.
Only copy floppy disks that are of the same size
and capacity.
If target disk is unformatted, DISKCOPY will
automatically format the disk first automatically.
Syntax
DISKCOPY [drive1: [drive2:]]/switches
DISKCOPY Options
/1 Copies only the first side of the diskette, even if the target
diskette is double sided.
/V Verifies that the source data was copied correctly onto the
destination drive. Selecting this option will slow down the
copying process.
/M Make use of RAM to speed up copy access.
DISKCOPY Examples
DISKCOPY a: b:
Copies the contents of the disk in drive A to the
disk in drive B (erasing any data already on the
disk).
DISKCOPY a: a:
If there is only one floppy drive then DOS first
reads the source floppy disk and then prompts
you to remove the disks and insert the target
disk.
XCOPY
Requires an external file XCOPY.EXE
Copy entire directory trees.
Xcopy is a version of the copy command that can
move files and directories from one location to
another.
Syntax:
xcopy <source_dir> <destination_dir>
XCOPY Options
/A Copies only files with the archive attribute set, doesn't
change the attribute.
/M Copies only files with the archive attribute set, turns off the
archive attribute.
/D:m-d-y Copies files changed on or after the specified date. If no
date is given, copies only those files whose source time is
newer than the destination time.
/P Prompts you before creating each destination file.
/S Copies directories and subdirectories except empty ones.
/E Copies directories and subdirectories, including empty
ones. Same as /S /E. May be used to modify /T.
XCOPY Options
/V Verifies each new file.
/W Prompts you to press a key before copying.
/C Continues copying even if errors occur.
/I If destination does not exist and copying more than one file,
assumes that destination must be a directory.
/Q Does not display file names while copying.
/F Displays full source and destination file names while copying.
/L Displays files that would be copied.
/H Copies hidden and system files also.
/R Overwrites read-only files.
/T Creates directory structure, but does not copy files. Does not
include empty directories or subdirectories. /T /E includes
empty directories and subdirectories.
XCOPY: Examples
C:\>XCOPY abc\*.txt D:
copies all files in the abc directory with the
extension .txt to drive D:
C:\> xcopy c: a: /s
Copies all files and directories (except empty
directories) from drive C to drive A.
DOSKEY
MS-DOS utility that allows a user to keep a
history of commands used on the computer.
Before using it, it is required to install doskey by
writing this command on the DOS prompt.
Syntax
doskey/options
DOSKEY Options
/HISTORY Displays all commands stored in memory
/LINE: size Sets maximum size of line edit buffer(default:128)
C:\>doskey /H
Displays a list of all the commands currently
stored in memory.
DEFRAG
ECHO Hello %1
When the above one-line batch file is created, add your name after the
batch file. For example, typing myname (being the name of the bat file)
and then your name:
myname bob
would output:
Hello bob
Command Description
:: One of two ways of adding remarks into the batch file without
displaying or executing that line when the batch file is run.
:LABEL By adding a colon in front of a word, such as LABEL, you create a
category, more commonly known as a label. This allows you to skip to
certain sections of a batch file such as the end of the batch file. Also
see GOTO.
CALL This is used to run another batch file within a batch file. When the
batch file that is called is completed, the remainder of the original
batch file is completed. Note if the batch file does not exist it will give
an error message.
CHOICE It allows to accept various user responses from a list of options.
CLS Just like the DOS command would clear your screen.
Commands
Command Description
ECHO Will echo a message in the batch file. Such as ECHO Hello World will
print Hello World on the screen when executed.
EXIT Exits out of the DOS window if the batch file is running from Windows.
REM One of two ways of adding remarks into the batch file without
displaying or executing that line when the batch file is run.
@ECHO OFF
IF EXIST %1 ECHO File %1 exists!
IF EXIST %2 ECHO File %2 exists!
IF EXIST %3 ECHO File %3 exists!
Pause Command
@ECHO OFF
ECHO The next command is a PAUSE
ECHO Do NOT press Ctrl+C or Ctrl+Break
PAUSE
ECHO Press Ctrl+C or Ctrl+Break
PAUSE
Looping in Batch Files
:TOP
DIR
GOTO TOP
Using variables
@echo off
set name=%1
set address=%2
set city=%3
Install
Used to install some executable programs after starting
of the computer.
This command speeds installation and minimizes
addressing problems.
Example:
install=abcd.exe
CONFIG.SYS Commands
Device
Allows us to install any hardware device that is supported
by DOS.
Helps to install the device drivers in your computer’s
memory.
Syntax:
device=<filename>
Example:
device=keyboard.sys
CONFIG.SYS Commands
Files
Used to set and specify the number of files that can be
opened simultaneously in DOS.
By default, the number of files are 8 and the maximum
number that can be specified is 255.
Example:
Files=20
CONFIG.SYS Commands
Last Drive
Used to tell how many drives are there in your computer.
By default, the last drive assumed to be E.
Syntax:
lastdrive=<drivename>
Example:
lastdrive=F
CONFIG.SYS Commands
Shell
DOS contains a file COMMAND.COM which is root
directory of the hard disk. This command helps to
specify another location for COMMAND.COM.
DOS
Used to load the operating system in the
conventional, extended or reserved memory.
AUTOEXEC.BAT