Batch file does not continue running commands

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
falcios
Posts: 43
Joined: 02 Mar 2017 05:38

Batch file does not continue running commands

#1 Post by falcios » 11 Dec 2018 06:53

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.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Batch file does not continue running commands

#2 Post by Squashman » 11 Dec 2018 08:18

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

falcios
Posts: 43
Joined: 02 Mar 2017 05:38

Re: Batch file does not continue running commands

#3 Post by falcios » 11 Dec 2018 09:47

Thanks Squashman, it worked great.

Post Reply