Thread: batch files

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    6

    batch files

    Aside from this being a bit of n00bish question, it is as you may have guessed, a batch problem. Either I don't know enough, or I don't the syntax. When I write a file and compile it into a .bat file, it does open and stay in place, but when I press enter it closes. It is supposed to ask a question. I put in an if statement. So basically it asks your age, and if it's less than 18 it says "not old enough" or something like it. But when I type in a number and press enter, it closes the window. Is it supposed to do that? Couldn't find it in any of my books so I turned to these forums.

    Enter your age:

  2. #2
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    Posts
    431
    1. This isn't really the appropriate place for this question.
    2. You don't compile batch files. They are interpretted.
    3. (I assume you are using Windows) Either run it from command line or put "Pause" as the last command.
    I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Moved to Tech Board.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User
    Join Date
    Nov 2008
    Posts
    6
    Quote Originally Posted by NeonBlack View Post
    1. This isn't really the appropriate place for this question.
    2. You don't compile batch files. They are interpretted.
    3. (I assume you are using Windows) Either run it from command line or put "Pause" as the last command.
    But that was in C

  5. #5
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    once the bat file finished the DOS box closes, this is normal behavior, if you wan ti tto wait then you need to add a PAUSE

  6. #6
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by Sm33zy View Post
    But that was in C
    Hence the reason why it didn't belong in the C Programming section - since it has nothing to do with C.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 07-24-2008, 09:02 AM
  2. Windows Vista Batch Files
    By Trennto in forum Windows Programming
    Replies: 2
    Last Post: 07-02-2008, 09:30 AM
  3. Program Deployment and DLL/OCX Files?
    By dfghjk in forum C++ Programming
    Replies: 5
    Last Post: 06-16-2008, 02:47 AM
  4. help running batch files
    By xxwerdxx in forum Tech Board
    Replies: 5
    Last Post: 09-25-2005, 12:58 PM
  5. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM