0% found this document useful (0 votes)
181 views3 pages

Batch Scripting Basics Guide

This guide provides an overview of common commands used in Windows batch scripting, including ECHO, SET, IF, and SHUTDOWN, along with their usage and examples. It also covers additional commands like PAUSE, TIMEOUT, and FINDSTR, and explains how to manage output redirection. Users are advised to save scripts with .bat or .cmd extensions and run them as administrator when necessary.

Uploaded by

ytmvlogs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
181 views3 pages

Batch Scripting Basics Guide

This guide provides an overview of common commands used in Windows batch scripting, including ECHO, SET, IF, and SHUTDOWN, along with their usage and examples. It also covers additional commands like PAUSE, TIMEOUT, and FINDSTR, and explains how to manage output redirection. Users are advised to save scripts with .bat or .cmd extensions and run them as administrator when necessary.

Uploaded by

ytmvlogs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Beginner's Guide to Windows Batch Scripting

This guide explains common commands used in Windows batch (.bat) scripts, with simple

examples.

------------------------------------------------------------

1. ECHO

Usage: echo Hello

- Displays text in the command window.

- Special: echo. adds a blank line.

- echo off hides command lines from displaying during execution.

- @echo off also hides the command itself.

2. SET

Usage: set name=value

- Stores a variable in the script.

Example:

set logFile=C:\Users\User\Desktop\log.txt

3. REM or :: (Comments)

Usage: rem This is a comment

- Used to write notes that don't run.

4. IF

Usage: if EXIST "file.txt" echo Found it!


- Conditional logic, based on file existence or variable value.

5. GOTO

Usage: goto start

- Moves script execution to a label like :start

6. PAUSE

Usage: pause

- Freezes script and shows: Press any key to continue...

7. TIMEOUT

Usage: timeout /t 10

- Waits 10 seconds before continuing.

8. SHUTDOWN

Usage: shutdown /s /t 60

- Schedules PC shutdown in 60 seconds.

- /s = shutdown, /r = restart, /t = time delay

9. START

Usage: start notepad.exe

- Opens a program or file.

10. FINDSTR

Usage: findstr "word" file.txt

- Searches for text inside a file (used to extract SFC results).


11. REDIRECTION

> = overwrite output file

>> = append to output file

Example:

echo Done > log.txt (overwrites)

echo Done >> log.txt (adds to end)

12. EXIT

Usage: exit

- Closes the script.

------------------------------------------------------------

TIP: Save batch scripts with the .bat or .cmd file extension and run them as administrator when

needed.

You might also like