Solved

Windows bat file that leaves the cmd window open and allows for more action

Posted on 2014-02-06
5
568 Views
Last Modified: 2014-02-06
I have a bat file that is:
cd C:\Users\Bob\addon-sdk
bin\activate

Open in new window

The point of the file is to open a cmd, go to a directory and start a service. What I want is to keep the cmd window open so I can start working but the cmd window always closes. I have tried pause and  cmd /k at the end of the file but the cmd window still closes.

Any idea?
0
Comment
Question by:phper
5 Comments
 
LVL 10

Expert Comment

by:remmett70
ID: 39840082
At the end of your bat file,  Just call CMD.exe itself.
0
 

Author Comment

by:phper
ID: 39840107
Did not work. Moreover, I want the current CMD window open not a new one. The idea is that the bat file will automatically do the first two steps of a process then I can take over and continue manually.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39840120
the solution would be to instead of calling the .bat file directly (like this)
"C:\My programs\test.bat"

Open in new window

would be to call it with the cmd.exe /K switch
C:\WINNT\system32\CMD.EXE /K "C:\My programs\test.bat"

Open in new window

hope this helps
0
 
LVL 53

Expert Comment

by:Bill Prew
ID: 39840140
How are you invoking this BAT file?

~bp
0
 
LVL 83

Accepted Solution

by:
oBdA earned 500 total points
ID: 39840147
This should work both when started from an open shell and from Explorer:
@echo off
setlocal
set Line=%cmdcmdline:"=%
if /i "%Line:~0,6%"=="cmd /c" cmd.exe /k "%~dpn0" %*
cd /d C:\Users\Bob\addon-sdk
bin\activate

Open in new window

0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question