Search code examples
windowscmd

CMD does not return to prompt when calling program at time of cmd call


I want to have a desktop shortcut/icon for a cmd prompt which runs a command when it is opened, but then returns to the prompt

I have something like this

C:\Windows\System32\cmd.exe /k "E:\python-gui.pyw"

When I run this the GUI launches as expected, but the command prompt does not return until the GUI closes.

If instead I open a

 cmd

and then run the command

 E:\python-gui.pyw

then the command prompt is available even while the gui remains on the screen. i.e. I can execute further commands.

Is there a way I can get this behavior from the first call?


Solution

  • As @KJ writes in the comments, a program which would lock the command window can be launched instead with the run command. Launching with the run command launches the program in its own command window, which prevents the original command window from waiting for the program to complete.

    waits for program to exit before returning control:

    C:\Windows\System32\cmd.exe /k "E:\my_script.script"
    

    does NOT wait for program to exit before returning control:

    C:\Windows\System32\cmd.exe /k start "E:\my_script.script"