Solved

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

Posted on 2014-02-06
5
576 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 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…
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

710 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