Search code examples
windowsbatch-filecmdwindows-xp

How to Close CMD after starting an program


I have wrote a batch file that opens two CMD windows in the folder I want so that I can run a server and type commands. I also want to be able to open firefox and sublime editor.

Everything works except I am left with 4 cmd windows not just the two I want.

@ECHO OFF
start cmd.exe /K "cd C:\xampp\htdocs\restful"
start cmd.exe /K "cd C:\xampp\htdocs\restful"
cd "C:\Program Files\Mozilla Firefox\"
start cmd.exe /K "firefox.exe"
cd "C:\Program Files\Sublime Text 3\"
start cmd.exe /K "sublime_text.exe"
exit

I am running on Windows XP for my sins, so if anyone can help I would appreciate it.


Solution

  • It should be

    @ECHO OFF
    start cmd.exe /K "cd C:\xampp\htdocs\restful"
    start cmd.exe /K "cd C:\xampp\htdocs\restful"
    cd "C:\Program Files\Mozilla Firefox\"
    start firefox.exe
    cd "C:\Program Files\Sublime Text 3\"
    start sublime_text.exe
    exit