Download Kurbaan 2009
Download Dragonball Evolution(2009)(In Hindi Dvdrip)
Download Outlander 2009 (Hindi Dvdrip)
Download Ajab Prem Ki Ghazab Kahani 2009
Download Tum mile 2009
Download Terminator Salvation Dvd rip [Hindi]
Download London Dreams (2009) movie
Download Angels And Demons(In Hindi Dvdrip)
Download Race to Witch Mountain(In Hindi Dvdrip)
Download Pirates Of The Caribbean : At World's End(Hindi Dvdrip)
Download BLUE 2009
Download Night at the Museum: Battle of the Smithsonian(In Hindi Dvdrip)

Wednesday, August 26, 2009

BATCH FILE PROGRAMING

Posted by Hellman at Wednesday, August 26, 2009

Your Ad Here

Ok. So here is the best batch tutorial ever made.

Lets start:-

To start off, there is the @echo off/on
and there is echo
and pause

So here is an example:

Quote:

@echo off
echo Hello This is a test
pause

Type this in notepad and save as test.bat
Launch it and it will look like this.

Quote:

Hello This is a test
Press any key to continue..

Again open notepad and write:

Quote:

@echo on
echo Hello This is a test
pause

and save it on the desktop as test2.bat

Quote:

Launch it and it will look like this

C:\Documents and Settings\User\Desktop>echo Hello This is a test
Hello This is a test
C:\Documents and Settings\User\Desktop>pause
Press any key to continue

So for the explanation

@echo off/on:
if you put @echo on it will show the directory as you just saw
if you put @echo off it will just show the words with no directories
So its best to use @echo off


echo:

If you want to type a simple phrase just type in echo and something in this case: echo Hello This is a test
which will show Hello This is a test

pause

pause will pause the batch file. If you press a key the batch will continue. In this case it will exit because there is no more left.

So try this:

Quote:

@echo off
echo Hello This is a test
pause
echo I am testing pause
pause

This will show

Quote:

Hello This is a test
Press Any Key To Continue...
(when you press a key it will show)
I am testing a pause
Press Any key to continue..

So that convers the pause command


Now some more commands


There is msg * and there is cls

Open notepad and write:

Quote:

@echo off
echo Hello This is a test
pause
cls
echo I am testing pause
msg * The End
pause

and save as test3.bat

This will show

Quote:

Hello This is a test
Press Any Key To Continue...
(when you press a key it will show)
cls
(the page will clear)
I am testing a pause
(a pop-up will show saying The End)
Press Any key to continue..

So .. cls will just clear the screen and msg * will bring up a pop-up


Other commands are REM and goto and start

So create a folder name it Test
Put any picture inside and name it testpic
Open notepad and type

Quote:

@echo off
echo Testing start and rem
rem title Test
start testpic.jpg (or any other extension)
pause

and save it inside the new folder as test4.bat

launch it , it will show:

Quote:

Testing start and rem
Press Any Key To Continue
(and the picture will launch)

So start will launch any file and rem is a remark.. which wont show in the bat file when running

Now the goto and set and if

type this inside notepad:

Quote:

@echo off
echo This is a test
echo If you want to do math type 1 and press enter
echo If you want to see a picture type 2 and press enter
set /p option=
if '%option%'=='1' goto :math
if '%option%'=='2' start testpic.jpg (or any extension)

:math
echo 2+2
pause

and save it inside the new folder

This will show

Quote:

This is a test
If you want to do math type 1 and press enter
if you want to see a picture type 2 and press enter
(here you can type 1 or 2 and press enter)
(if you press 2 and Enter the picture will load)
(if you press 1 and enter this will show up):
2+2
Press any key to continue.

So goto will go to a Label or a Part of the file
When you put :Math, a new label will be named Math and when you put goto :math the batch will go to :math



set

The set option will set something. Here its going to set :choice
The set is, in some options followed by if
So if I type 1 in this example:-
the "choice" will be 1 .. and it will go to :math because we put
if '%choice%'=='1' goto :math

so if we put 1 the choice will be 1 therefore it will goto :math


Anyway those are the basics..
stay on rapidpiracy.com and wait for more batch tutorials.. Next time it will be more advanced




Now, I am going to talk about call, exit and SHIFT

Go into notepad and type this:

Quote:

@echo off
echo yay me i know the basics of batch
call call.bat
pause
exit
and save in a new folder:)
Then open note pad and type this again:
Quote:
@echo off
echo I Love S*X
pause

and save in the same folder that you save the last one... and name it call.bat

launch the first one

This will show:

Quote:

yay me i know the basics of batch
I Love S*X
Press Any Key To Continue....
(when you press a key the below will appear)
Press Any Key To Continue
and when you press a key it will exit

ok.. so now you know what exit does. It exits the file and calls
So now for SHIFT which is a little hard so try to understand




SHIFT

If Command Extensions are enabled the SHIFT command supports the /n switch which tells the command to start shifting at the nth argument, where n euh.. can be between zero and eight.
Just like this 1 below


SHIFT /2

would shift %3 to %2, %4 to %3, etc. and leave %0 and %1 ..euh.. how can i say it.. .:S.. unaffected yea thats the word .

Examples



The below has got to be saved as .bat. So just name it test.bat
Quote:

@ECHO OFF
ECHO - %1
SHIFT
ECHO - %1

After creating the above example test.bat file, if you were to type the below command at the MS-DOS prompt, it would print "- ONE" and then "- TWO"; this command is commonly used to work through each of the command extensions or remove command extensions.

Ok I hope you understand


Now, we will learn how to launch windows applications:

Type in notepad:

Quote:

@echo off
echo I am testing notepad!
start /MIN notepad
pause


This will show:

Quote:

i am testing notepad
(and notepad will start minimized.. if you put /MAX instead of /MIN it will launch maximized)
Press Any Key To Continue

Now lets learn how to put a timeout inside a batch..

Go to notepad and type:

Quote:

@echo off
echo i am trying timeout
set wait=0
:pause1
set /a wait=%wait%+1
if %wait% leq 1000 goto pause1
echo IT WORKED!\
pause

Don't understand the command.. just copy paste it.. or memorize it .. if i tell you the explanation it will take years!!..

So this will show:

Quote:
i am trying timeout
(couple of seconds and.. )
Press Any Key To Continue...
Now ill teach you how to change the TIME

Go to notepad and type:

Quote:

@echo off
echo Gee!.. i wonder what time it is!!
TIME 5:50
echo Oh so its 5:50
pause

This will show:

Quote:
Gee!.. i wonder what time its is!!
Oh so its 5:50
The TIME will just change The TIME





Now the Color

Go into notepad and type this:

Quote:

@echo off
echo trying the colors
pause
color 04
echo testing
pause
color f
echo trying
pause
color 4f
echo trying
pause
04=background black and font red

f the font will be white
4f = background red and f = white

Here are the list(that can be found by cmd>color help)

Quote:

0=black
1=blue
2=green
3=aqua
4=red
5=purple
6=yellow
7=white
8=gray
9=light blue
a=light green
b=light aqua
c=light red
d=light purple
e=light yellow
f=bright white

Now the title:

Type this in notepad:

Quote:

@echo off
tile Test
echo trying the title
pause

This will show the title Test When you launch it!!

Lets try Shutdown/Restart

Type this in Notepad:

Quote:

@echo off
START C:\Windows\RUNDLL.EXE user.exe,exitwindowsexec
exit

The above will restart

Quote:

@echo off
Shut down the computer
C:\Windows\RUNDLL32.EXE user,exitwindows
exit

The Above will Shutdown

So, thats it. I hope it was useful to you. It is just a basic batch tutorial. You will find more tutorials on RP made by RP members. So, keep searching for them.

DOWNLOAD notepad file here---





If you enjoyed this post and wish to be informed whenever a new post is published, then make sure you subscribe to my regular Email Updates. Subscribe Now!



Thanks For Making This Possible! Kindly Bookmark and Share it:

Technorati Digg This Stumble Facebook Twitter Delicious
YOUR ADSENSE CODE GOES HERE

1 comments:

Anonymous said...

nice sharing man!!

Confused? Feel free to ask

Your feedback is always appreciated. I will try to reply to your queries as soon as time allows.
To leave a comment, choose Name/URL. Write your name and your website URL. If you don't have a website than leave the URL box empty.
(Use Tab Key if Proper comment box is not appear for scrolling)

Note:- Please do not spam. Spam comments will be deleted immediately upon my review.

Regards,
Hellman

:a   :b   :c   :d   :e   :f   :g   :h   :i   :j   :k   :l   :m   :n   :o   :p   :q   :r   :s   :t

Sponsors

 

About Me

My photo
Hi World! I am an addicted blogger, programmer and a computer enthusiast. I am a certified Ethical Hacker. I love socializing with people and making new friends. I write Pc Black Stuffs.com
Regards,
Hellman___

Extras


Top100 Bloggers - Top Blog Directory - Blog Top list
BlogRankers.com Entertainment PC BLACK STUFFS - Blogged Blog directory Computers blogs Hollywood Dubbeb movies in Hindi Add to Technorati Favorites Entertainment Blogs - Blog Rankings

Featured Posts

F-A-C-T

Since- AUG 05 2009
Best View - 1024 x 768 (FIREFOX)
Last Update - NOV 24 2010

| PC Black Stuffs,Hindi Dubbed Hollywood Movies,Bollywood Movies,Hackers Need © 2009. All Rights Reserved | Admin: Hellman | Back To Top |