Saturday, 6 February 2010

Primary - Batch Codes

To make a batch file you right a command or more in notepad or notepad++ (Any other program doesn't work!) and save it .bat (batch).

CODES:

Copy:

copy (((Location of the file to copy)))\(((File name))).(((File extension))) (((Destiny of the file)))

For example - You want to copy the file Explorer.exe from C:\WINDOWS to C:\=

copy C:\WINDOWS\explorer.exe C:\

This will copy the explorer application
to the C: drive
__________________________________________________________________________________

Delete:
This one is even easier than the copy!!

del (((Location of the file, file & its extension/Directory)))


For example, let's say you wanted to delete folder (Directory) X from the C: drive, the code would be this:

Del C:\X

As Easy as that!!

___________________________________________________________________


Echos:
Echos are line of word in a batch file, but it has many other uses

For a line of words, tipe in a new command line the word
"echo" -space- ((the text))
Let's say you wanted the batch file to say hello, the text would be this:

@echo off
echo Hello
pause
exit

@echo off means the echo is desactivated, this means any process will not be showed.
pause means to pause the whole process, to continue it, press any key.
exit means that that's the end off the batch, making it close, putting this isn't nessesary
but it keeps everything in order.

___________________________________________________________________________

Title:
To put a title on your batch files simply put the place you want the title to act,
Title (((the title)))
lets say that you want the title to be "Batch Files", but later you want it to be
"Title changed", the code would be:

@echo off
title Batch Files
echo This is a Batch file
Pause >nul
echo Now the title will change
Pause >nul
title Title changed!
echo See!!
Ping localhost -n 2 >nul
echo The title changed!!!
pause >nul

>nul Means that any process behind it in the same command line will not be showed,
using it after th Pause means that the message "Press any key to continue" will not be showed.
Ping localhost -n 2 pings the local IP adress to 127.0.0.1
(2) times, Then 127.0.0.1 loops back the ip, this takes 1 second to finish aprox, so in result you get a pause for 1 second long, without having to press anything.
___________________________________________________________________________

Colours:
You can change console color combination by tiping the next codes:

0 = Black

1 = Dark blue
2 = Green
3 = Aquamarine
4 = Dark Red
5 = Purple
6 = Yellow
7 = 25% Grey

8 = 50% Grey
9 = Blue
A = Light green
B = Light blue
C = Red
D = Pink
E = Light yellow
F = White

For there to be any color type in the batch file the code:
Color (((code of the background)))(((code of the letters)))
For example, Color FC makes the background white and the letters red,
0C makes the background black and the letters green.

@echo off
Color 0c
echo Now the colors are kinda like matrix
pause >nul
Color F0
echo Now the colours are black and white, very pleasent to the eye...

Pause >nul
exit
___________________________________________________________________________

Set:
For information obout "Set" command click HERE
(I'ts too much to explain!!)

No comments:

Post a Comment