to open up the command prompt in any version of windows, go to the start menu, click run and type “cmd” in the box.
run > cmd
syntax list:
- “netstat” checks and shows that connections are established and which ports are listening.
- “ping” brings up a menu to ping various connections.
- “iprelease” releases your ip address
- “iprenew” renews your ip address
- “ipconfig” configure IP
- “reg” Read, Set or Delete registry keys and values
- “regedit” Import, export or delete registry settings from a text (.REG) file
- “CONVERT” Convert a FAT drive to NTFS.
CHKDSK [drive:][[path]filename] [/F] [/V] [/R] [/L[:size]]
Key
[drive:] Specify the drive to check.
filename Specify the file(s) to check for fragmentation (FAT only).
- /F Automatically Fix file system errors on the disk.
- /X Fix file system errors on the disk, (Win2003 and above) dismounts the volume first, closing all open file handles.
- /R Scan for and attempt Recovery of bad sectors.
- /V Display the full path and name of every file on the disk.
- /L:size NTFS only: change the log file size to the specified number of kilobytes. If size is not specified, displays the current log size and the drive type (FAT or NTFS).
- /C Skip directory corruption checks.
- /I Skip corruption checks that compare directory entries to the file record segment (FRS) in the volume’s master file table (MFT)
COLOR [background][foreground]
Sets the default console foreground and background colours.
Colour attributes are specified by 2 of the following hex digits. Each digit can be any of the following values:
- 2 = Green
- A = Light Green
- 5 = Purple
- D = Light Purple
- 6 = Yellow
- E = Light Yellow
- 7 = White
- F = Bright White
DEL [options] [/A:file_attributes] files_to_delete
Delete one or more files.
Key
files_to_delete : This may be a filename, a list of files or a Wildcard
options
/P Give a Yes/No Prompt before deleting.
/F Ignore read-only setting and delete anyway (FORCE)
/S Delete from all Subfolders (DELTREE)
/Q Quiet mode, do not give a Yes/No Prompt before deleting.
/A Select files to delete based on file_attributes
file_attributes:
R Read-only -R NOT Read-only
S System -S NOT System
H Hidden -H NOT Hidden
A Archive -A NOT Archive
Wildcards: These can be combined with part of a filename
* Match any characters
? Match any ONE character
Examples:
To delete HelloWorld.TXT
DEL HelloWorld.TXT
To delete “Hello Big World.TXT”
DEL “Hello Big World.TXT”
To delete all files that start with the letter A
DEL A*
To delete all files that end with the letter A
DEL *A.*
To delete all files with a .DOC extension
DEL *.DOC
To delete all read only files
DEL /a:R *
To delete all files including any that are read only
DEL /F *
Folders
If a folder name is given instead of a file, all files in the folder will be deleted, but the folder itself will not be removed.
Temporary Files
You should clear out TEMP files on a regular basis – this is best done at startup when no applications are running. To delete all files in all subfolders of C:temp but leave the folder structure intact:
DEL /F /S /Q %TEMP%
When clearing out the TEMP directory it is not generally worthwhile removing the subfolders too – they don’t use much space and constantly deleting and recreating them can potentially increase fragmentation within the Master File Table.
Deleting a file will not prevent third party utilities from un-deleting it again, however you can turn any file into a zero-byte file to destroy the file allocation chain like this:
TYPE nul > C:examplesMyFile.txt
DEL C:examplesMyFile.txt
Undeletable Files
Files are sometimes created with the very long filenames or reserved names: CON, AUX, COM1, COM2, COM3, COM4, LPT1, LPT2, LPT3, PRN, NUL
To delete these use the syntax: DEL \.C:somedirLPT1
Alternatively SUBST a drive letter to the folder containing the file.
If a file (or folder) still appears to be ‘undeletable’ this is often caused by the indexing service.
Right click the file you need to delete, choose properties, advanced and untick “allow indexing” you will then be able to delete the file. To cure the problem permanently – Control Panel, Add/Remove programs, Win Accessories, indexing service.
Delete Locked files (Typically IE temp files or the Offline cache)
This works on any version of NT, 2000 or XP
Close all applications
Open a command prompt
Click Start, and then Shut Down
Simultaneously press CTRL+SHIFT+ALT.
While you keep these keys pressed, click Cancel in the Shut Down Windows dialog box.
In the command prompt window, navigate to the cache location, and delete all files from the folder (DEL /s)
At the command prompt, type explorer, and then press ENTER.
DELTREE
Previous versions of Windows had the DELTREE command that deletes all files and sub folders.
DEL /s will delete all files
RD /s will remove all files and folders including the root folder.
:: Remove all files and subfolders but NOT the root folder
:: From tip 617 at JsiFAQ.com
@echo off
pushd %1
del /q *.*
for /f “Tokens=*” %%G in (‘dir /B’) do rd /s /q “%%G”
popd
Normally DEL will display a list of the files deleted, if Command Extensions are disabled; it will instead display a list of any files it cannot find.
ERASE is a synonym for DEL
DIRUSE [options] Folders…
Display disk usage.
Options
/M Display in Mb
/K Display in Kb
/B Display in bytes (default)
/, Use thousand separator when displaying sizes.
/Q:# Quota limit, mark folders that exceed the size (#) with a “!”.
set %errorlevel% to ONE if any folders are found that
exceed the specified size
/* Report on one level of subfolders (top-level folders)
/D Display only folders that exceed specified sizes.
/S Include detail of every subfolder in the output
/O Don’t check subfolders for quota overflow.
/V Display progress report for every subfolder
/C Use Compressed size instead of apparent size.
/L Output overflows to logfile .DIRUSE.LOG.
/A generate an alert if quota is exceeded
(requires the Alerter service)
EXIT [/B] [exitCode]
Quit CMD.exe or the current batch script.
Key
/B When used in a batch script it will exit the
current batch script instead of CMD.EXE.
If executed from outside a batch script, it
will still quit CMD.EXE
exitCode A numeric number. if /B is specified, sets
ERRORLEVEL that number. If quitting CMD.EXE, sets the process
exit code with that number.
KILL [option] process_id
KILL [option] task_name
KILL [option] window_title
Option
-f Force process kill
Note: Kill -f basically just nukes the process from existence, potentially leaking a lot of memory and losing any data that the process hadn’t committed to disk yet. It is there for worst case scenarios – when you absolutely must end the process now, and don’t care whether proper cleanup gets done or not.
LOGOFF [/f] [/n]
Key
/f Force running processes to close, but will ask for user confirmation.
The user will not be asked to save unsaved data.
/n Force running processes to close without confirmation.
The user will be prompted to save unsaved data.
By default LOGOFF will ask for user confirmation and prompt to save unsaved data.
Windows XP includes the SHUTDOWN command that can now logoff a user.
In WindowsXP, KILL is replaced with the superior TASKKILL – Allowing you to specify a remote computer, different user account etc – for more details run TASKKILL /?
MEM
Display memory usage
MEM /C
MEM /D
MEM /P
Key
/P List programs in memory
with the memory address and size of each
/D List Programs(as /P) and also Devices
/C List programs in conventional memory and
list programs in upper memory
MEM will only display details about the current CMD shell environment, programs running in a separate shell (or WIN32 programs) will not be listed – so it won’t tell you anything about total memory usage.
RECOVER [drive:][path]filename
Recover is designed to help in the case of hardware failure. When a drive fails the failure is not always total, in other words you may be able to read some of the files but not others, and some files will be only partly readable.
The data on a disk is stored in tracks and sectors in an almost random manner. Data stored in a bad sectors cannot be read.
RECOVER reads a file sector by sector and recovers data from the good sectors. You must specify a file.
Recover will not allow you to undelete a file.
Recover files one at a time; move each file to a good disk before editing to re-enter missing information.
In the case of complex documents you will probably lose formatting/graphics but will retain raw text.