Solved

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

Posted on 2014-02-06
5
582 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 56

Expert Comment

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

~bp
0
 
LVL 85

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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
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 …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

617 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