0

If I run a batch file from windows (Start->Run, "mybatch.bat"), a window pops up, it executes, and then it closes. I'd like it to stick around in this usage.

However, if running the same batch file from an existing terminal, I'd like it to use the current terminal, versus opening another one.

Is this possible?

1

1 Answer 1

0

That should be the normal behaviour. This batch:

:: Q:\Test\2017\07\19\WhoStartedMe.cmd
@Echo off
Echo %cmdcmdline%
pause

shows with what cmd line the batch was started and waits for any key
Started win Win+R

C:\WINDOWS\system32\cmd.exe /c ""Q:\Test\2017\07\19\WhoStartedMe.cmd" "
Press any key to continue . . .

Started from an open cmd window:

> WhoStartedMe.cmd
"C:\WINDOWS\system32\cmd.exe"
Press any key to continue . . .

Started from an open Powershell window:

PS> .\WhoStartedMe.cmd
C:\WINDOWS\system32\cmd.exe /c ""Q:\Test\2017\07\19\WhoStartedMe.cmd""
Press any key to continue . . .

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .