Learning Basic Batch
Batch files are very old school but can be used to do a variety of dangerous things if the computer is not protected and the file is coded properly. Below is a quick review and teaching of basic batch. Go to Start > Run > type CMD inside command prompt type: notepad.exe batch files are made using this very simple method.
While most batch files are made using notepad they can be created with pretty much with any software that you can type on as long as any built-in spell checker doesn't auto correct your typing and mess up your hard work, so for that reason it is best to use plain old notepad.
To create the batch file use notepad and navigate to: File > Save As then save the file as what ever name you want followed by .bat change the second drop down box to "all files" then hit save. Remember batch files always start with: @echo off
While most batch files are made using notepad they can be created with pretty much with any software that you can type on as long as any built-in spell checker doesn't auto correct your typing and mess up your hard work, so for that reason it is best to use plain old notepad.
To create the batch file use notepad and navigate to: File > Save As then save the file as what ever name you want followed by .bat change the second drop down box to "all files" then hit save. Remember batch files always start with: @echo off
Explanation |
Example Code |
This first demonstration shows how to use the echo, pause, and title commands in a batch file. Echo outputs the text onto the screen and can be turned either on or off. Pause asks the user to hit a key to continue the program and title sets the title of the batch when running.
|
|
This next batch shows how to use *msg and cls. *msg outputs a simple message box displaying some text and cls clears all data from the current screen.
|
|
The two new commands here are Rem and Start, start starts a given file or website and Rem is a remark or comment that won't be shown in the final code.
|
|
The new commands here are Call, Exit and Del commands. Call is used to call other batch files like this: call test.bat, exit closes the batch file and del deletes files or filetypes using a wilcard ( * ) and a file extension.
|
|
Some other command in batch are shutdown, and copy. Shutdown of course turns your computer off in a given time which is called ( -t then a number goes here ) and copy copies a file to a given area on a computer.
|
|