HOME       >>       Programming

Batch .bat Files not sure which subforum this would go in


sorry, im not really sure where this would go, as im just starting to hear alot about them and dont know what language theyre in.


i had just a few questions tho,

What language are .bat files written in?

Is there a way to run them without the black box popping up?

what are some of the things that you can do with them? i know about ftp stuff, but i havent done much else :S


others can correct me if im wrong but i belie .bat files (Batch files) are just a collection of commands that run in DOS on windows so technically theyre not written in any programing language as they arent a program as such just commands for another program.And i dont think there is a way of stopping the black box coming up becuase the black box is MS-DOS which is what takes the instructions you write into the batch file and does whatever they tell it to do.As for what it can do i dont think its very much, its usually used for recovering a computer if everything goes wrong and you can use DOS and batch files to try and fix things because they dont need windows to load to work also i use them to shutdown faster sometimes just one line of commands can shutdown my computer a lot quicker than the usual way.they can be used for things like telnet and other DOS applications and for checking network configurations and things like that but overall batch files are only really usefull for technicians and techie minded computer users rather than for a general home user who wants to do office work or play games, they are usefull for things ive already mentioned though. I think you can find a list of the uses and commands by searching for MS-DOS commands in googleBut like i said i might be wrong so others please correct me but i think im right!


Batch files are written as simple "phrases" that your computer recognizes as commands when you save your file as .bat. For instance, open up Notepad. Then type in command.com, (without the comma) which is the phrase that tells the computer to open up command prompt. Then go to File-Save As-then save as whatever you want, and at the end, type .bat, and make sure where it says Save As Type you select All Files. Then open the file up and it will open up Command Prompt. If you do some research online you can find and memorize a simple list of commands to put in a batch file and pretty soon instead of opening up Command Prompt and trying to configure your IP address, you can simply write a batch file that opens it up and it does it for you.

@echo off:AClsecho MESSENGERset /p n=User:set /p m=Message:net send %n% %m%PauseGoto A

If you save that in a batch file, you've just created an instant messenger that runs through Command Prompt, and all you need is your friend's IP address.


.BAT (Batch files) can be looked upon as a shell scipt, because, that's wtah they actually are... Theya re plain text file, with simple structure, and a list of commands that operating system has to execute... These commands are not really commands, such as found in programming languages, but rather, OS commands, and program names... So, for example, you could set some temporary environment variable, and then execute some game, and after that game exits, clear that variable...Batch files could perform simple branching, variable comparisons, text input, OS command execution, and program execution... Try to obtain manual or help files for MS-DOS 6.22... You can find more info there, on batch file specific commands....BAT files were uses while MS-DOS existed, and were useful, if you had to do same operations constantly, to avoid typing the same sequence of commands over and over again... Since MS-DOS no longer exists (it's only emulated in WindowsXP), and due to graphical operating system, .BAT files lost some of their use... They still do the same thing, they did years ago, but are obsolete now...Think of batch files as a form of Unix shell scripts...


At one point I was looking up things you can do with them and different commands you could use, and I found this: http://www.computerhope.com/msdos.htm. It's a big list of all the DOS/command prompt commands, what they do, and how to use them.


um potatoes and actually its just the obsolete version of dos  it is for back up perpouses only if you really want to mess of have fun with something just use regular dosit is really kind of useless unless you want to back up some files or recover them also it is the "quick and dirty way"  to edit txt files


yeah, ms-dos batch files are still used for about everything, and can be modified to do just about anything, seeing as the mainframe of the computer is pushed behind batch files and dll extentions. 

-reply by rawr



what to doBatch .bat Files

Replying to brandon10092I copy and pasted@echo off:AClsEcho MESSENGERSet /p and=User:Set /p m=Message:Net send %and% %m%PauseGoto AThat into notepad saved it as ms.Bat and opened it again ti comes up withMESSENGERUSER:MESSAGE:What do I type after that

-reply by zero-coo



HiI am trying to use a batch file for inputting variables into a program and it works for the variables which are input before running the code, but not after. Here's how I approach it:1- make a batch file containing this line:code.exe < input.txt2- enter variables in the input.txt, e.g:yes2input.in1output.out3- run the batch file. It reads the input variables and runs the code, but after finishing the code, doesn't write the results into output.outAny idea?Thanks


Batch files can do many many things, including games,messengers, folder lockers, fake viruses, to solve prob with computers

I love batch files and the bat to exe converter. 

-reply by yourface



You can make batch games by using simple if statements.
For example, try copying this into a batch file for a basic text game:

@echo offtitle Interactive Story// This makes the commands themselves invisible, and titles the command prompt "Interactive Story".:menucolor f0// This sets the colors of the command prompt.cls// This clears the command prompt of all messages.echo Welcome to Interactive Story!echo For each section, write your choice, then press enter.echo Please write your choice in lowercase.echo Beware, making the wrong choice will kill you.echo Have fun!pausegoto start// This sends the command interpreter to a different line of code.:start// This is the title of the line of code.color f0clsecho You find yourself in a strange room.echo There is a green door and a red door.echo Which door do you go through? (Only write the color.)set /p choice=Choice:// This is creating a variable.if %choice%==green goto right1if %choice%==red goto death1// These are if statements. They are basically saying "if (condition) (some command)".echo Invalid choice, please try again.// If you type in something that is not "green" or "red" the of code will repeat itself.pausegoto start:death1// Getting to this line of code means you lost.color f4clsecho You open the red door, and come face to face with the last thing you see...echo fire.echo THE ENDpausegoto menu:right1// Getting to this line of code means got it right.color f2clsecho You open the green door and you are in a hallway.echo Which way do you go, left or right?set /p choice=Choice:if %choice%==left goto death2if %choice%==right goto right2echo Invalid choice, please try again.pausegoto right1:death2color f4clsecho You run to the left.echo All of a sudden, the sound of cracking pierces your ears.echo A crack opens in the floor... and you fall to your death.echo THE ENDpausegoto menu:right2color f2clsecho You run to the right and into a new room.echo All of a sudden, an alien soldier appears in front of you,echo armed with plasma launchers.echo Do you fight or flee?set /p choice=Choice:if %choice%==fight goto right3if %choice%==flee goto death3echo Invalid choice, please try again.pausegoto right2:death3color f4clsecho You run away from the alien.echo All of a sudden, you are surroundedecho by dozens of alien soldiers.echo And there is no surrendering in this game!echo THE ENDpausegoto menu:right3color f2clsecho You kick the alien in the chest and take its plasma launcher.echo You shoot the alien and run, but other aliensecho are among you.echo However, they are afraid of you, and flee from the room.echo The weapon you are holding looks dangerous.echo Should you keep it or drop it? (Write "keep" or "drop")set /p choice=Choice:if %choice%==keep goto death4if %choice%==drop goto right4echo Invalid choice, please try again.pausegoto right3:death4color f4clsecho You decide to keep the weapon.echo It is far too awesome to be dropped.echo However, you are not quite sure how all the functions work,echo so you decide to fiddle around with it.echo You find a big red button on the gun and press it.echo It self destructs and so do you.echo THE ENDpausegoto menu:right4color f2clsecho You decide to drop it.echo It is far too dangerous to be kept.echo You hide it in a closet and run out of the room.echo You face two new doors: a blue one and an orange one.echo Which one should you go through? (Only write the color.)set /p choice=Choice:if %choice%==blue goto right5if %choice%==orange goto death5echo Invalid choice, please try again.pausegoto right4:death5color f4clsecho You open the orange door and walk in.echo The sound of slithering makes you stop in your tracks.echo You look down and find out that the floorecho is made of poisonous snakes!echo You feel a sharp pain in your ankle and drop dead.echo THE ENDpausegoto menu:right5color f2clsecho You open the blue door and walk in.echo You are in a flooded room.echo You see another door and a skylight.echo Should you exit through the door or the skylight?set /p choice=Choice:if %choice%==door goto death6if %choice%==skylight goto right6echo Invalid choice, please try again.pausegoto right5:death6color f4clsecho You open the door and enter.echo Slam! You turn around and it is closed.echo You try opening it but it is locked.echo There are no other doors.echo Looks like you're going to be in hereecho for a long time...echo THE ENDpausegoto menu:right6color f2clsecho You decide to exit through the skylight.echo You spot a ladder and climb it.echo You open the skylight and above you is the sky!echo You are free!echo Or are you?echo Above you, you see the alien ship leaving.echo All of a sudden, you are being pulled into the ship.echo You are inside the ship.echo You see an airlock.echo Perfect! Your way out!echo Should you exit or stay?set /p choice=Choice:if %choice%==exit goto death7if %choice%==stay goto right7echo Invalid choice, please try again.pausegoto right6:death7color f4clsecho You decide to get out of the ship.echo After all, there are evil aliens here.echo You open the airlock.echo Miles off the ground, you fall towards the Earth.echo Gravity is a devil!echo THE ENDpausegoto menu:right7color f2clsecho You decide to stay in the ship.echo Who knows where that airlock leads to?echo You decide to explore the ship.echo All of a sudden, you realize that you're hungry.echo You find some mushroom things that look like food.echo Should you eat them or explore the ship?echo (Write "eat" or "explore")set /p choice=Choice:if %choice%==eat goto death8if %choice%==explore goto right8echo Invalid choice, please try again.pausegoto right7:death8color f4clsecho You pick them up and eat them.echo They taste horrible!echo Like a mix between cow manure and rotten eggs.echo Suddenly, you feel a pain in your stomach.echo You fall to the ground.echo Next time, be careful with what you eat!echo THE ENDpausegoto menu:right8color f2clsecho Those mushrooms are probably poisonous.echo You want to explore the ship.echo You hide when you see a group of aliensecho coming your way.echo When the coast is clear, you run into another room.echo You are in the main control room.echo You can defeat these aliens by crashing the ship!echo Should you crash the ship? (Write "yes" or "no")set /p choice=Choice:if %choice%==yes goto right9if %choice%==no goto death9echo Invalid choice, please try again.pausegoto right8:death9color f4clsecho You decide not to crash the ship.echo You can get yourself killed.echo The sound of footsteps makes you turn around.echo The aliens are coming your way!echo You have nowhere to hide.echo They come in and capture you due to a reportecho on a human in the control room.echo Looks like you've just become a slave...echo THE ENDpausegoto menu:right9color f2clsecho You decide you want some action.echo You look at all of the buttons.echo You don't know what they do.echo Then, you notice an antimatter bomb is storedecho in the compartment.echo You set it off.echo You have one minute to exit the ship.echo You hide when you hear the sound of footsteps.echo You go back to the airlock.echo You open it, and you are looking into the thermosphere.echo Should you jump? (Write "yes" or "no")set /p choice=Choice:if %choice%==yes goto right10if %choice%==no goto death10echo Invalid choice, please try again.pausegoto right9:death10color f4clsecho You don't want to fall to your death,echo so you stay in the ship.echo All of a sudden, you hear a cracking rippling sound.echo The antimatter bomb must have gone off.echo The ship dissolves in a flash of light, and nothing is left of you.echo THE ENDpausegoto menu:right10// Getting to this line of code means you won.color f2clsecho You close your eyes and jump.echo Above you, the ship explodes,echo sending ripples across spacetime.echo The air around you becomes liquid,echo and you cease to fall.echo The very matter around you is being ripped apart.echo You are in a vacuum. When the air comes back,echo you are on the ground.echo Good job! You defeated the aliens!echo You are the celebrated hero of Earth.echo THE ENDecho Play again?set /p choice=Choice:if %choice%==yes goto yesif %choice%==no goto noecho Invalid choice, please try again.pausegoto right10:yesclsgoto menu// The batch file will run again.:noclsexit// The command prompt will close.


Xisto.com offers Free Web Hosting to its Members for their participation in this Community. We moderate all content posted here but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 2001-2019 by Xisto Corporation. All Rights Reserved.