Table of contents
Common Commands
echo
This parameter will allow you to view your working script in the command prompt.
This parameter is useful for viewing your working code.
If any issues arise from the batch file, you will be able to view the issues associated with your script using the echo function.
Adding the following off to this parameter will allow you to quickly close your script after it has finished.
cls
Clear your command prompt, best used when extraneous code can make what you’re accessing had to find.
rem
Shorthand for remark provides the same functionality as
<!--
tag inHTML
.
statements are not entered into your code.
Instead, they are used to explain and give information regarding the code
%%a
Each file in the folder.
(".\")
The root folder.
When using the command prompt, one must direct the prompt to a particular directory before changing a file name, deleting a file, and so on.
With batch files, you only need to
paste yourBAT
file into the directory of your choosing.
pause
Allows a break in the logical chain of your
BAT
file.
This allows for users to read over command lines before proceeding with the code.
The phrase “Press any key to continue…” will denote a
pause.
start "[website]"
Will head to a website of your choice using your default web browser.
ipconfig
This is a classic command prompt parameter that releases information concerning network information. This information includes
MAC
addresses,
IP
addresses, andsub-net masks
.
ping
Pings an
IP
address, sending data packets through server routes to gauge their location and latency (response time).
net use
Connects a computer to or disconnects a computer from a shared resource, or displays information about computer connections. The command also
controls persistent net connections. Used without
parameters, net use retrieves a list of network connections.
XCopy
/y
Suppresses prompting to confirm that you want to overwrite an existing destination file.
/q
Suppresses the display of xcopy messages.
/s
Copies directories and subdirectories, unless they are empty.
If you omit /s, xcopy works within a single directory.
/i
If a source is a directory or contains wildcards and destination does not exist, xcopy assumes destination specifies a directory name and
creates a new directory.
Then, xcopy copies all specified files into the new directory.
By default, xcopy prompts you to specify whether the destination is a file or a directory.
/r
Copies read-only files.
/c
Ignores errors.
/e
Copies all subdirectories, even if they are empty.
Use /e with the /s and /t command-line options.
/h
Copies files with hidden and system file attributes.
By default, xcopy does not copy hidden or system files
/j
Copies files without buffering.
Recommended for huge files.
This parameter was added in Windows Server 2008 R2.
Personal Use Example
cd "C:\Users\%USERNAME%\source\repos\GitHub\Veridian";
git pull
::xcopy "C:\Users\%USERNAME%\source\repos\GitHub\Veridian\Google\Default\*" "C:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data\Default\"/y /q /s /i /r
xcopy "C:\Users\%USERNAME%\source\repos\GitHub\Veridian\Google\Default" "C:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data\Default"/y /q /s /i /r /c /e /j
Quick Scripts
run msi for only current user
From an elevated process call to perform an advertisement. This blesses the package.
msiexec /jm foo.msi
From a standard user process call and this will start the installation off as the user but elevate seamlessly as needed.
msiexec /I foo.msi REBOOT=R /qb
Check time
echo %date% %time% & tzutil /g
output
Central Standard Time
Force delete
RMDIR /S /Q
Change TimeZone
check timezone
tzutil /g
list timezones
tzutil /l
set timezone
tzutil /s
Create a symbolic link
mklink /D \"E:\\Path\\newFolder\" \"F:\\folderIwantToLinkFrom\"
Get WIFI password
netsh wlan show profile ALLO1D67CF_5G key=clear
power managment
Power saver
powercfg -duplicatescheme a1841308-3541-4fab-bc81-f71556f20b4a
Balanced
powercfg -duplicatescheme 381b4222-f694-41f0-9685-ff5bb260df2e
High Performance
powercfg -duplicatescheme 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
Ultimate Performance (available since Windows 10 April 2018 Update)
powercfg -duplicatescheme e9a42b02-d5df-448d-aa00-03f14749eb61