Hillingdon U3A Computer Group
WINDOWS
COMMAND PROMPT
(Intermediate)
U3A Presentation J. Martin 2021
MS-DOS was the main command-
line interface operating system for
IBM PC compatible personal
computers during the 1980s.
By the 1990’s it had been
replaced by the Graphical user
interface (GUI) WINDOWS
operating system, of which
Windows 10 is the latest.
However a version of MS-DOS still exists
within the WINDOWS operating system as
the Command Prompt and can still be very
useful.
The Command
Prompt is
accessed using
cmd
By default it opens in
your
c:\users\[username]
folder
Sometimes cmd needs to be run in Administrator
mode.
Right click on “Command Prompt” and select
“Run as administrator”
For more information on all Command Prompts
and their options
got to:
https://ss64.com/nt/
Commands are not case sensitive
Navigation
Navigate through the folders of your hard
drive by typing the change directory command
cd
Such as: cd c:\users
List Files in Directory/Folder
List the files in a folder by using the Directory
Command prompt
dir
To list the files in sub
folders as well use the
/s option
dir /s
CMD Command Options
Nearly all Commands allow options to vary the
result of the Command
For dir:
To list the files in sub folders as well as the
main directory use the /s option
dir /s
Copying and Moving Files
It is easier to do this using the Windows File
Explorer but it can also be done by using the
Command prompts copy and move.
To copy the file myphoto.jpg from the current
folder to folder c:\photobackup, you would
enter:
copy myphoto.jpg c:\photobackup
To copy all jpg files in the current folder to folder
c:\photobackup, you can use a wildcard “*” and
would enter:
copy *.jpg c:\photobackup
You can also use a question mark to represent
individual characters, thus to copy all Word
documents starting with “letter” followed by one
extra character (letter1, letter2….):
copy letter?.txt c:\
Files can be deleted using the Delete Command
prompt del
del c:\photobackup\me.jpg
del also accepts the wildcard “*”
View a map of your folders
Use Command prompt
tree
Redirect Command Output to a File
To do this use the operator “>”
dir c:\users > c:\output.txt
File Commands
File Commands generally work only on TEXT
files.
If you want to process information from other
types of file such as WORD documents.
1. Open the file in the correct software.
2. Select all the data and copy
3. Open Notepad
4. Past the copied data
5. Save the text file
To view contents of file
Type c:\output.txt
To sort a file redirecting output
Sort c:\input.txt > c:\output.txt
To search for a text string in a text file
Findstr “Name" Address.txt
Search for "granny" OR "Smith" in the files
Apples.txt or Pears.txt
Findstr "granny Smith" Apples.txt Pears.txt
Search for "granny Smith" in Contacts.txt
Findstr /C:"granny Smith" Contacts.txt
Pipe Command output to another Command
To do this use the operator “|”
Pipe the output of a DIR command into SORT
DIR /b “c:\demo\" | SORT
/b Bare format (no heading, file sizes or summary)
Pipe the output from DIR into SORT, reverse
the list and save into a file
DIR /b | SORT /r /o demo.txt
/R[EVERSE] Reverse the sort order (Z to A, 9 to 0)
/O[UTPUT] [drive:][pathname]
Find Files
Find files in a folder by using the Where Command
List all the .CSV files in both the work and play
folders:
WHERE c:\work\;c:\Play\:*.csv
Create a Virtual Drive
WINDOWS only recognises Partitions and physical
drives as separate drives.
Using the Substitute Command prompt subst, you
can change any folder into a virtual drive:
subst f: c:\users\[username]\Pictures
To remove a virtual drive use the /d switch
subst f: /d
File Associations
File Associations dictate what program your file
will open in. Thus a .doc or .docx file will usually
open in MS WORD.
To see the current
associations use the
Command prompt
assoc
Check if file is a duplicate
If you have two files which you think are duplicates
then use the File Compare Command prompt fc to
check.
fc c:\users\[username]\test.txt c:\test2.txt
Encrypt files
(not available on Windows 10 Home)
To encrypt a folder so that the files can only be
accessed using your login
cipher /e c:\vault
(replace c:\vault with the required folder)
To decrypt use the /d switch:
cipher /d c:\vault
View running tasks and related services
tasklist -svc
View running Window Apps
tasklist -apps
To stop an App you need to use taskkill
taskkill /PID 14332 /f
SOLVE PROBLEMS USING CMD
Your Windows computer keep crashing or
appears to not be working correctly.
Check and fix a corrupt Windows Operating System
cmd (run as Administrator)
Check for system file corruption with the
System File Checker Command prompt:
sfc /scannow
To repair:
DISM /Online /Cleanup-Image /RestoreHealth
While the SFC command checks the integrity of
system files, you can use the Check Disk Command
prompt chkdsk to scan an entire drive.
The /f switch will automatically Fix file system
errors on the disk.
cmd (run as Administrator)
chkdsk /f C:
Network Problems?
Find out your computer’s name on the
network
Use Command prompt hostname
Display details of your network
Use the Configure IP Command prompt
ipconfig /all
Check if connected to internet
Use Test Network Connection Command
prompt ping to connect to a known website
ping www.google.co.uk
Reveal which programs are connected to the web
cmd (run as Administrator)
Now use the Display
Networking Statistics
Command prompt:
netstat -b
Wi-fi not be working correctly or slow
Check signal strength:
netsh wlan show interfaces
If < 50% try moving your
router to another position.
If signal strength is not the problem.
Try resetting the Winsock Settings (if they get
corrupted you will loose access to your
network):
netsh winsock reset
Reset your computer’s IP Address (if two
devices have the same IP address, both will
fail). To release:
ipconfig /release
To renew:
ipconfig /renew
Also worth purging your DNS history:
ipconfig /flushdns
If your wi-fi is still slow.
netsh int tcp show global
“Receive Windows
Auto-Tuning Level”
should be set to normal
If “Receive Windows Auto-Tuning Level” is not
set to normal
netsh int tcp set global autotuninglevel=normal
netsh interface tcp show heuristics
“Windows Scaling
heuristics” should be
set to disabled
If “Windows Scaling heuristics” is set to enabled
netsh int tcp set heuristics disabled
Restart your computer and test your wi-fi
Forgotten your Wi-fi password:
netsh wlan show profile
This will show
your Wifi-name
netsh wlan show profile [WIFI-name] key=clear
The Wi-fi password
is shown against
“Key Content” under
“Security settings”
System Information.
Use the Command
prompt:
systeminfo
Check your laptops battery.
Use the Configure Power Settings Command
prompt:
powercfg /batteryreport
Open the file that
has been created
Find your Windows product key.
Wmic path SoftwareLicensingService get
OA3xOriginalProductKey
Change a forgotten Windows password.
If someone who uses your computer forgets their
Windows login, then you can reset the password:
cmd (run as Administrator)
net user Steve newpass
(where Steve is the username and newpass the
new password)
For more information on all Command Prompts
and their options
got to:
https://ss64.com/nt/