I have a simple batch file that sets some necessary per-session path information and then launches an application:

SET PATH=%PATH%;C:\Qt\473_x64\lib;C:\Qt\jom
start C:\Qt\qt_creator_220_x64\bin\qtcreator.exe

It is working fine except that it keeps open a ghost command window. This command windows shuts down when the application shuts down. To be clear, the command window that comes up when I initially double-click the batch file closes. It is a new window that opens up. How do I prevent this second window from displaying? I would like to just double-click on a short cut to the batch file and it open the application as if I had double-clicked on the application itself. (Plus, of course, setting the necessary path information.)


I'm curious what your application does. Because this has nothing to do with the batchfile. The batch file only opens one window and clearly closes. Any subsequent windows are caused by QTcreator.

Look at this question and see if the edits are similar to yours.


  • Success! It was rather similar to that link. I built Qt Creator in debug mode, which added the testlib library, which made it use the console subsystem. Building it in release mode took out that library and now it opens without the extra window. – Dave Aug 12 '11 at 13:30

If there is only the one command, you can get rid of start so that it opens in the same process.

Alternatively and a better solution is to use the /b switch so that start does not open a new window.

From your example, this would be start /b C:\path\to\application.exe

  • If I add /b it keeps the original window open. – Dave Aug 11 '11 at 20:19
  • If I get rid of the start it keeps the original window open as well. – Dave Aug 11 '11 at 20:20
  • Ahh, sorry, misunderstood the environment... a couple of things to try is to rename from .bat to .cmd and also it is worth a try to create a shortcut to your file and run the shortcut instead of the original... Please can you try these things? ... Also, try putting an exit at the end of the file! – William Hilsum Aug 11 '11 at 20:26
  • Thanks for the ideas. I tried every combination of cmd/bat; /b; shortcut I could think of and still no solution. :( Maybe you just can't do this? – Dave Aug 11 '11 at 20:36
  • @Dave - I am sure you can... If there is nothing sensitive, can you tell me a little more here or email me (details on my profile) of the program/script and I will see if I can come up with a solution... It is one of those things that just seems simple and annoying when it doesn't work - I remember trying something very similar for myself a while ago! – William Hilsum Aug 11 '11 at 20:39

All you have to do is add exit to the end of your batch script and it will close the command prompt window after launching your program.

  • No, that doesn't change anything. – Dave Aug 11 '11 at 20:35
  • 1
    @Dave Oh, I misunderstood the original question. I didn't realize there was a second console window opening after the first one closed. I haven't been able to reproduce it (was testing with Notepad.exe). Perhaps it's just a behavior of the application you're running? – Ben Richards Aug 11 '11 at 20:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.