129

I am in the process of setting up CruiseControl.NET. The problem I am having is that I am running CC as a console application and when my build completes successfully and executes (using exec) it launches it within the CruiseControl DOS prompt. I am just using simple batch files to launch my app but having it run within the same prompt as CC is causing CC to think the build continues as long as my app runs.

Are there command line parameters to cmd.exe that will spawn another separate prompt window?

1
  • 1
    cmd.exe is a CUI shell, not a GUI. It doesn't create windows. It uses a console window that's created and managed by an instance of conhost.exe, the console host process. If a CUI program is started normally, initialization code in the base client DLL (kernel32.dll or kernelbase.dll) inherits the parent's console, if any, or allocates a new console, unless it's started with the creation flag DETACHED_PROCESS (i.e. no console). If it's started with the creation flag CREATE_NEW_CONSOLE (as CMD's start uses), the base DLL always allocates a new console instead of inheriting the parent's.
    – Eryk Sun
    Commented Jun 9, 2018 at 15:05

12 Answers 12

244

I think this works:

start cmd.exe
4
  • 5
    make sure you check out all the different options for start "start /?" /wait and /I can be usefull. Commented Dec 20, 2008 at 23:43
  • 55
    fwiw, you don't even have to put 'cmd.exe' after start. just the word 'start' will do it.
    – JustJeff
    Commented Nov 16, 2010 at 12:27
  • 1
    start /d <path> For those who want to set path for new cmd window. Here detailed description.
    – anton.mo
    Commented Jan 4, 2018 at 13:55
  • or just start
    – user11543803
    Commented Mar 16, 2022 at 14:54
79

Here is the code you need:

start cmd.exe @cmd /k "Command"
5
  • 14
    What is the @cmd doing? Is there some documentation for it?
    – michas
    Commented Jul 19, 2014 at 19:41
  • 2
    @ supresses the direct output which normally would show up in the prompt but the command will still be executed. Commented Sep 28, 2016 at 18:42
  • I used this, it works but if try to kill the running program by keyboard interrupt ctrl+c, running program does not stop. It only stops when you close the newly opened command prompt window.
    – Sachin G.
    Commented Apr 12, 2018 at 7:43
  • Doesn't work for multi-line commands using ^. :( Any way to deal with this? Commented Mar 14, 2019 at 12:41
  • @cmd appears to be redundant here. Exactly the same bahviour without it. I'm assuming cmd.exe silents ignores it as it's an invalid option. You can replace @cmd with (almost) any old junk and you'll see the same behaviour.
    – Jimadine
    Commented Feb 24, 2022 at 12:41
46

Simply type start in the command prompt:

start

This will open up new cmd windows.

0
22
start cmd.exe 

opens a separate window

start file.cmd 

opens the batch file and executes it in another command prompt

7

You can just type these 3 commands from command prompt:

  1. start

  2. start cmd

  3. start cmd.exe

5

simple write in your bat file

@cmd

or

@cmd /k "command1&command2"
1
  • 4
    Thanks for the & to execute multiple commands in the new prompt. I like to add exit so it closes the prompt when the command have finished running.
    – Sylhare
    Commented Aug 28, 2017 at 15:32
3
START "notepad.exe"
echo Will launch the notepad.exe application
PAUSE

To make any cmd file type, all you have to do is save the contents as .bat, i.e.

@echo
TITLE example.bat
PAUSE
taskkill/IM cmd.exe

Make that into an "example.bat" file, save it, then open it and run.

2

launch_stack.bat will open 2 windows to run your alices.bat and bobs.bat

start alices.bat
start bobs.bat
1

If we simply use start command or start cmd.exe it opens cmd.

If you want to open the same command prompt window;

start "Command Prompt"
0

I also tried executing batch file that run daemon process/server at the end of CCNET task; The only way to make CruiseControl spawn an independent asynchronous process WITHOUT waiting for the end of process is:

  1. create a batch file to run the daemon process (server application)
  2. use task scheduler to run the batch file as CCNET task (using schtasks.exe)

    schtasks.exe /create /F /SC once /ST 08:50 /TN TaskName /TR "c:/path/to/batchFileName.bat"
    
    • 08:50 is the HH:MM time format

you might need to kill the process at the start of ccnet

PS: the selected answer using "start cmd.exe" does not work; a new command prompt is indeed spawned, but CCNET will wait for the spawned cmd to finish.

0

You can write in command line this command

cmd

Previous command will open in current command line with new session

OR

start

0
conhost

Optionally, conhost program, e.g. conhost powershell

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