Solved

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

Posted on 2014-02-06
5
571 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 143

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 54

Expert Comment

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

~bp
0
 
LVL 84

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
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 …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

685 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