How to make the most dangerous scripts
How to make the most dangerous scripts
Any Guesses?
Yeah!!!
You guesses it right. We are going to learn the basics of batch scripting.
In Windows , the batch file is a file that stores commands in serial order. Command line interpreter takes the file as an input and execute in the same order.
Exciting? Let’s learn more about it…….
First Shot!
Here is our first batch file :
ECHO
OFF
ECHO
Technical Sapien
PAUSE
After saving it with .bat
extension. Double click it run the file. It will show:
What happened here?
In above script, ECHO off cleans up the consol by hiding the commands from being printed at the prompt, ECHO prints the text “Technical Sapien” to the screen, and then waits for the user to press a key so program can be ceased.
Here we created a batch file, batch file is a simply text file saved with the .bat file extension. It can be written using Notepad or any other text editor.
Some basic commands of batch file :
· echo – Prints out the input string. It can be ON or OFF , for ECHO to turn the echoing feature on or off. If ECHO is on the command prompt will display the command it is executing.
· Cls – Clears the command prompt screen.
· Title – Changes the title text displayed on the top of prompt window.
· Exit – to exit the command prompt.
· Pause - Used to stop the execution of windows batch file.
· :: - Add a comment in the batch file.
· COPY – Copy a file or files.
Types of “batch” diles in
windows:
· INI (*.ini) – Initialization file. These set the default variables for the system and programs.
· CFG (*.cfg) – These are the configuration files.
· SYS (*.sys) – System files , can sometimes be edited, mostly compiled machine code in new versions.
· COM (*.com) – Command files. Yhese are the executable files for all the DOS commands. In early versions there was a separate file for each command. Now , most are inside COMMAND.COM.
· CMD(*.cmd) – These were the batch files used in NT operating systems.
Let’s take another example :
Suppose we need to list down all the files/directory names inside a particular directory and save it to a text file, so batch script for it will be:
@echo
off
Rem
Listing all the files in the directory
Program files
Dir “C:
\Program Files” >
C:
\technical_list.txt
Echo “Done!”
It will create a file
name technical_list.txt in your C:\ directory, displaying all the files/folder
names in C:\Program Files.
One more example :
Another useful batch script
that can be written to diagnose your network and check performance of it.
:: This
batch file checks for network connection problems.
ECHO
OFF
:: View
network connection details
Ipconfig
/all
::
Check if technicalsapien.com is reachable
Ping
technicalsapien.com
:: Run
traceroute to check the rout to technicalsapien.com
Tracert
technicalsapien.com
PAUSE
This script gives information
about the current network and some network packet information.
Comments
Post a Comment