Jump to content

Batch file Programming...!


Recommended Posts

Maybe i posted in wrong section..coz i didn't found appropriate section for it to post...

so lets start...

Basics..:batch file are programmed in notepad and saved with an extension *.bat :)

2.it runs in command prompt...

..lets move to create our first one..

open notepad..

type the follwing commands..


cd windows


so lets analyse the code given above..

the first tells COMMAND.COM to go to to c:

second line tells us that change the current directory to c:\windows..

the third line tells open telnet in c:\windows...u observed why i not put .exe with telnet..

ANSWER:The exe extension is automatically added by command.com  :);):D;;):x

lets proceed next learn some more new commands....

The REM Command:the most simple and basic batch file command is REM or Renmark command.It is used extensively by programmers to insert comments into their code to make it more readible and understandable.this command ignores anything there is on that line.anything after REM is not even displayed in screen during excution.It is not narmally used in small programs ..It is written in big programs to make it more smooth...

ECHO:The ECHO command has several different uses. MS DOS batch files use two echo 'modes'. The default echo mode is ECHO ON. When ECHO is set to ON, every command in the batch file is displayed to the screen before it is run. Sometimes this information is not required, and can even be downright annoying for larger batch files. The command ECHO OFF sets the batch echo mode to OFF. In this mode, the commands are not printed to the screen prior to their execution.

As well as the echo modes, the ECHO command is used to print a message to the user. Messages are displayed to the user by preceding a line of text with ECHO.

The command @ECHO OFF is almost always placed at the top of a batch file to switch off subsequent command echo.

ECHO is also the only way a batch file can communicate information to a user.

Pause:The PAUSE command prints the message "Press any key to continue..." to the screen and waits for the user to respond.

U hav seen that when u install a rip game @ end when command prompt extraction beging  it says extraction will take 10-15 minutes ...

press any key to continue....

here pause is used to let the users read and continue..if not used this command extraction automatically continue before ur eye blinks...

IF:(imp)The IF command is used in batch files to test whether a condition is met or not. This allows the batch file to perform a particular action only if a particular condition is met. There are several different variations of the IF command: IF EXIST, IF ERRORLEVEL, and IF x == y (yes! it does use two equal signs!)




IF %1 == "" GOTO ERROR

Call:The CALL command is used to run another batch file from within a batch file. Execution of the current batch file is paused and the called batch file is run. After the called batch file has finished running, the original batch file is resumed at the line after the CALL statement.

Note: If another batch file is run from within a batch file by simply using its name, after the called batch file finishes executing, control is returned to the Command Line, NOT the original batch file.

u hav seen how automatically the cmd opens aftr installation..its the call command inserted in exe file to launch the cmd...

the rest commands are more typicall but u should learn them using google...to learn batch file programming in u hav to be practical...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...