Solved

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

Posted on 2014-02-06
5
558 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
Comment Utility
At the end of your bat file,  Just call CMD.exe itself.
0
 

Author Comment

by:phper
Comment Utility
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]
Comment Utility
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 51

Expert Comment

by:Bill Prew
Comment Utility
How are you invoking this BAT file?

~bp
0
 
LVL 82

Accepted Solution

by:
oBdA earned 500 total points
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now