Page 1 of 1

Batch file does not continue running commands

Posted: 11 Dec 2018 06:53
by falcios
I'm testing this sample batch file using the /k switch

cmd.exe /k winver
pause

However, once it runs winver it is back to the command prompt. How do I setup batch file to continue processing commands?

Thanks in advance.

Re: Batch file does not continue running commands

Posted: 11 Dec 2018 08:18
by Squashman
That is a loaded question. You need to better explain what your real task is and why you think you need to use CMD /k.
Because you seem to want to use CMD /K, this would be your only option.

Code: Select all

@ECHO OFF
cmd.exe /k "winver &exit"
PAUSE
So you need to explain why you wouldn't just run this?

Code: Select all

@ECHO OFF
cmd.exe /c "winver"
PAUSE
Or this

Code: Select all

@ECHO OFF
winver
PAUSE

Re: Batch file does not continue running commands

Posted: 11 Dec 2018 09:47
by falcios
Thanks Squashman, it worked great.