Windows Command
Line Tutorial
Overview
• Windows File System
• Create folders and files
• File Copy & Deletion
• Networks
• Search for information
• Create a batch file
Windows File System
Windows System file structure (Tree-
like)
Absolute and relative paths
• Absolute path
• a path is built starting from
the system root
• Relative path
• a path is built starting from
the current location,
• as it is relative to the current
present position location
how to access the file
Example of paths
• Write an absolute path to [Link]
• D:\Java\beginner\[Link]
• Under Beginner folder, write path to
[Link]
• absolute path
• D:\Java\Advanced\[Link]
• relative path
• ..\Advance\[Link]
How to Open Command Prompt?
Method 1 Method 2
Absolute path example
Root directory
A volume or drive letter C:
\Users
\Fxu
Change path using relative path
C: C:
Change to an upper directory
\Users \Users
\Fxu
Now you are here
You are here
9
C: C:
Change to an upper directory/root
\Users
How does Windows find/run your
applications?
Assume you want to open Notepad.
1. Search for the [Link] in the current
folder
2. if the [Link] in the current folder,
execute it
3. otherwise search all paths defined by
Windows
Displays or sets a search path for executable files
Display root
Displays a disk volume label and
serial number
Change to \users directory
cls Clears the screen
Show all files under the \Users
Change directory to \Public and
display the content of the folder
Help command
Get help when use dir
Find the owner of the file
Create folders and
files
23
C: C:
\Users \Users
Create a folder
\Public \Public
\workspace
24
Create a new text file C:
\Users
\Public
\workspace
hello
world my_first_file.txt
Show the content of the file: type
Show the content of the file
Show the content of the file: exe
command
File Copy & Deletion
29
Duplicate files
Copy a file to a different location
Copy a file to a new folder \
workspace2 without using cd
command
C: 1. create a folder
2. copy a file
.. parent folder
\Users
1. create a folder
2. copy a file
\Public
you are here
\workspace \workspace2
copy the whole folder to
/workspace3
C:
\Users
\Public
you are here
\workspace \workspace2 \workspace3
?
Rename a file
Delete a file
Delete a folder (rmdir/rd)
Change to a different drive
Networking
IP and default gateway
Test network connection
Test network connection
Search for information
How to search for a string in a file?
How to find system information?
How to find specific system
information using pipeline |
How to find system information
Windows Management Interface Command
using wmic?
find property using get
Find CPU/disk information
How to Find the MAC Address of Your
Computer ?
List Processes
List all Chrome Browser process
Create a batch file
Create a “Hello world” batch
Execute “Hello World” batch
Batch for showing system
information
Execute the batch sys_info.bat
Where you are? Show sys information
Assignment
• Make the file sys_info.bat callable at any folder
• create a new folder, e.g., workspace4
• copy the .bat to the new folder
• modify the path variable to add the new folder
• make sure the .bat can be executed