Question:

Cant use batch files?

by  |  earlier

0 LIKES UnLike

I am just learning batch language and I am having trouble opening the batch files I made. On a tutorial for learning it it says to type this into word pad to make it say Hello World:

@echo

echo Hello World

After I type that in and save it as helloworld.bat and open it the command prompt screen flashes and thats it and nothing happens. What should I do?

 Tags:

   Report

7 ANSWERS


  1. Simple:

    Start -> Run -> cmd -> enter

    Drag and Drop .Bat file into cmd console window -> enter

    Presto, solved.


  2. Batch (*.bat) Files are used to Activate the one or More Functions or  one or more Commands. This type of Batch files are used in starting the Operating System (OS). A single batch file contains many functions. We can active that file to do all functions at the Fraction of Seconds...

  3. You're probably not doing anything wrong.  Are you double-clicking on the file name to run the batch file?  If so, I'd say it's working beautifully - it just hasn't been told to stay open for you to look at.

    There are a few options for you:

    1. Open a command prompt and run the program from there.

    2. Run it from Start --> Run with a switch to keep the window open.

    3. Add pause as the last line so the window stays open until you press a key.

    If you do 1, you can write the programs in there too.  To write that program and run it from a command window, I would take these steps:

    a) Click on Start --> Run.

    b) Type in cmd (or command if cmd gave me an error message) and click Ok.

    c) At the command prompt, type:

    edit helloworld.bat

    d)  Write in my file and then save and exit (you should be able to use the mouse in here - if not just use the menus like you normally would in Windows).

    e) At the command prompt I would type:

    helloworld

    If using option 2, I would do this:

    a) Click on Start --> Run.

    b) Type in the path to my batch file (or browse for it) and THEN...

    c) I would add cmd /k at the beginning just before the file name (space after cmd and before / and then lower case k then space before the file name) for example:

    cmd /k c:\helloworld.bat

    d) Click OK.

    The window stays open until you close it.

    If using option 3, I would do this:

    a) Edit my file to read:

    @echo

    echo Hello World

    pause

    b) Run my program and press a key to answer the pause at which point the program will terminate and the window close.

    ************

    To move around in DOS between folders, use cd and then add where you want to go:

    A folder name that is in the folder you are in.  Add inverted commas if there is a space in the name of the folder you want to go to.

    cd \ to go back to the top of the disk drive.

    cd .. to go back up one folder.

    cd \

    cd ..

    cd batchfiles

    cd "batch files"

    *********

    One other thing I would suggest - use NotePad instead of WordPad because WordPad puts in formatting and NotePad doesn't and I don't recall if that's a problem with batch files.  I know I never have used WordPad for batch files.

    Have fun!!  :-)

  4. click Start --> Run --> type cmd

    The command prompt should come up.

    Copy the full path of helloworld.bat including the file's name. Paste it in the command prompt then Enter.


  5. That happens because windows automatically closes the command prompt window once the batch file finishes executing.

    You can do things,

    1. Run the batch file from the prompt itself, dont let windows open the prompt. You can do this by opening Command Prompt yourself, by clicking on Run and typing cmd. Then get to the folder where the file is and then execute it from there.

    2. Or you could add Pause after you've finished typing your commands. Pause waits for a key press before proceeding further. This would enable you to see what's on the screen before it closes.

    Hope this helps.

  6. command promt is fairly basic, depends how you use it

    Back to basic, there is a free back to basic prog for download, very helpful in creating bat files

  7. It might be because the command prompt from the batch just starts up, executes the echo command, and then shuts itself down right away so you never actually see the command prompt long enough.

    If your OS allows the "start" command, try this instead so that the command prompt stays open after it runs its echo command:

    start echo Hello World
You're reading: Cant use batch files?

Question Stats

Latest activity: earlier.
This question has 7 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.