TallBrianL
TallBrianL

Reputation: 1252

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?

Upvotes: 0

Views: 465

Answers (2)

TallBrianL
TallBrianL

Reputation: 1252

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"

Upvotes: 1

user17293366
user17293366

Reputation: 1

Create a new file for example I will name it a.bat

put this in it

E:\python-gui.pyw

Go to the original file and add this command

start a.bat

Upvotes: 0

Related Questions