Basic Windows Commands
Change Directory
Change the drive:
To see current location:
Change Directory to SystemRoot
System Information (systeminfo)
Displays detailed information about the system including OS version, hardware specs, network configuration andf uptime
Windows Version
Show Current User
detailed info
Print a message
Display Enviornment Variables
List all system enviornment variables and their values
Display System PATH
shows the directories where executables files are searched when running cmmmands.
Create a file ( > Redirection Operator)
View File Contents
Define a enviornment variables
Retrieve the value of an enviornment variable
dir command
Display help for dir command.
Listing file and folder
Display Short File Names (8.3 format)
Display file and folder in Bare format
/a = Displays all files, including hidden and system files
/a:hs = Lists only hidden and system files
/b = shows filesnames only, without additional details
/p = Stops output after each screenfull
/s = List all files in all subdirectives recursively
/l = Converts filenames to lowercase
/o:gn = sorts files with directories first, then alphabatically
/v = shows extra information like file attributes and last access time
/x = Displays the short (8.3) filename format
List Only Hidden and System Files (recursive)
List only hidden files (Recursive)
Create a New folder
Create folder in specific path
Create multiple folder at once
Create Nested Directories (Subdirectories in One Command)
Delete Files and Folders
Delete Folder (rd or rmdir)
Delete a folder without confirmation(/q)
Delete a folder and its content (/s /q)
/s = deletes the specified folder and all files and subfolders inside it.
/q = Quiet mode, deletes without confirmation
Delete a file (del)
Delete a specific file with confirmation (/p)
Delete files recursively (/s /f /q)
/s - Deletes all matching files in subdirectories
/f - force delete read-only files.
/q - Quiet mode (no confirmation)
Rename a File or folder(ren or rename)
Display or set date and time
Get MAC Address of the system
Exit Command prompt
Change command prmpt title
Displays " Press any key to continue ..." and waits for user input
change command prompt Display
Call Another Batch File (call)
runs runme.bat without stopping the current
Copying files and folders in Windows
Basic Copying with Copy
/a - specifies the source file (ASCII mode).
/v - verifies the copied file for accuracy.
/y - suppresses confirmation prompts when overwriting existing files.
Advanced copy with XCOPY
it is more powerfull alternative to COPY for copying directories, files and subdirectories. It can copy multiple files at once
/a - Copies only files with archieve attribute.
/d - Copies files modified after a specific dates
/p - Prompts before copying each file.
/s - copies directories and subdirectories, except empty ones.
/v - verifies copyied files
/w - waits for confirmation before starting
copies everything from c:\inetpub (including subdirectoreis) to c:\data\
Robust copying with ROBOCOPY (Recommeded) ROBOCOPY (robusty file copy) is a more powerfull tool introduced in later windows versions
Copies all files form c:\data to C:\data1 including subdirectories.
Copies a specific files
Copy specific file types, Copies all .js, .css and .html files from C:\data to their respective folders
Copy Multiples File types
Additional options
/r:1 - Retries once if a file fails to copy
/w:1 - Waits one second between Retries
/ndl - Prevents directories from being listed in the output.
/xjd - Excludes junction points (to avoid infinite loops).
Changing File and Folder Attributes Using ATTRIB
The ATTRIB command in windows allows users to modify file and folder such as hidden, system, Read-only and archieve
Basic Syntax, Displays the attributes of a file
Displays help information for the attrib command.
+H/-H - Adds/Removes the Hidden Attributes
+S/-S - Adds/Removes the System Attributes
+R/-R - Adds/Removes the Read-Only attribute
+A/-A - Adds/Removes the Archieve attribute
/S - Applies changes to all subdirectories
/D - Applies changes to directories
Modifying File Attributes, make a file Hidden, System and Read-Only
Remove System, Hidden and Read-Only attributes
Applying attributes to all files in a Directory
Remove Hidden, System and Read-Only attributes from all files
Unhiding all files on a drive
protecting a file from accidential deletion
Restarting a Windows System immediately without any delay
/s - shutdown the computer
/r - Restart the computer
/t 0 - set the time delay to 0 seconds(immediate restart)
/f - force close all running applications without warning
Allow user to cancel shutdown
Last updated