TechSpot

Command Prompt Won't Remain Open When Running C/C++ Scripts

By Jasio-
Mar 14, 2007
  1. Just wondering how to fix this, whenever I run a C/C++ script, the command prompt window will close as soon as the task is complete. I would prefer it remain open to read the status, or run other tasks on it.

    Thanks,
    Ross
     
  2. LNCPapa

    LNCPapa TS Special Forces Posts: 4,371   +289

    Putting a pause at the end should keep it open - but not allow you to use the command window after that.
     
  3. Jasio-

    Jasio- TS Rookie Topic Starter Posts: 95

    Is there any way to keep it from automatically closing?.. something preferably that isn't required in the script itself.
     
  4. jobeard

    jobeard TS Ambassador Posts: 13,515   +336

    try using RETURN instead of EXIT?
     
  5. SNGX1275

    SNGX1275 TS Forces Special Posts: 12,687   +334

    What if you open a command prompt first, then execute the script from within the prompt. I don't know the context in which you are running, but for example typing ipconfig from the Start -> Run leaves the window open in 9x, but in 2k and beyond it doesn't, so you have to launch the command prompt first, then enter ipconfig.
     
  6. tipstir

    tipstir TS Ambassador Posts: 4,754   +96

    put a wait trigger in the script so it doesn't close out on you..
     
  7. jobeard

    jobeard TS Ambassador Posts: 13,515   +336

    try run->cmd /k $any-command
    the window is retained AFTER the completion of $any-command
    ie: /k == KEEP :)
     
Topic Status:
Not open for further replies.


Add New Comment

TechSpot Members
Login or sign up for free,
it takes about 30 seconds.
You may also...


Get complete access to the TechSpot community. Join thousands of technology enthusiasts that contribute and share knowledge in our forum. Get a private inbox, upload your own photo gallery and more.