Auto-Closing Command Windows, How to stop

An extremely annoying feature of windows... if you type "ipconfig" (or any other command line program) in the Run dialog box, the program runs, then instantly closes after it has completed execution. This also happens for any batch files I run. I also have cscript associated with my vbs files... it would be really nice if I could just double click those and see the result.

I'm looking for a way to globally stop this action from happening. I have done it before but I think it was in Windows 98... and I cant even remember how I did it. Is there a way to have these programs stay open after execution?

Keep in mind I'm not looking for work-arounds to this. I dont want to have to add "Pause" to my batch files or anything like that. I want to be able to type ipconfig, arp, netstat, ping, or any other command line program from the run dialog box and have the window stay open.

This option has to be there somewhere. So far hours of searching and a few message board posts have revealed nothing... someone here must know. Anyone?
RabidSquirrelAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
mrdtnConnect With a Mentor Commented:
In case I wasn't explicitly clear, type

cmd /k ipconfig

instead of just

ipconfig

in the Run dialog.

Same goes for other commands.

--

mrdtn
0
 
BrianGEFF719Commented:
what you need to do is open the Command Window first:

Click Start
Click Run
Type CMD
when the dos window comes up, type ipconfig.


Good Luck
-Brian
0
 
RabidSquirrelAuthor Commented:
No thats exactly what I'm not looking for.

"Keep in mind I'm not looking for work-arounds to this"

"I want to be able to type ipconfig, arp, netstat, ping, or any other command line program from the run dialog box and have the window stay open"
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
mrdtnCommented:
This is what you need to do:

Use:

cmd /k ipconfig

instead of what you were doing.

Same for the other commands.

--

mrdtn
0
 
RabidSquirrelAuthor Commented:
That does nothing for my batch files and vbs files that I wish to double-click
0
 
mrdtnCommented:
I'm sorry, I was reading the first post and overlooked the detail to your original one.

--

Let me think . . . and I will post shortly . . .
0
 
chadCommented:
warning:... workaround listed ahead.  I have been looking for an option to keep windows open and cant find one.  Still looking though
for batch files... you could put in a pause or keystroke at the end.  hit the space bar to continue type of thing
0
 
RabidSquirrelAuthor Commented:
No problem mrdtn, many other people on the other boards I posted on said the same thing. Let me know if you find anything out. You will be my personal hero if you get this... plus you'll get 500 points :)

Kabaam,
Yeah I know about putting "pause" at the end of my batch files... that still leaves my vbs files though. I dont see the error messages if they fail.
0
 
mrdtnCommented:
This may be considered a "workaround", but I invented a cool method for doing something similar a while back.  As far as the START | RUN stuff, what I said still goes.  As far as batch files go, add the following teo lines to the very beginning of any applicable batch:

@if "%1"=="" cmd /e:on /v:on /k %0 spawn
@if "%1"=="" goto :eof

You don't really need the "/e:on /v:on" part of it.  That simply enables command extensions and delayed variable expansion.  If you don't have any idea what I'm talking about, don't worry.  Leave the command line as it is or omit the stuff in wuotes from earlier in this sentence.

--

mrdtn

--

I hope this is a reasonable solution.  Otherwise, I don;t believe the Windows OS offers any global capability for what you are asking.
0
 
mrdtnCommented:
The keyword "spawn" is a dummy keyword and can be anything.

These two lines cause the batch to re-execute itself "according to it's own rules" when it is invoked.

--

mrdtn
0
 
mrdtnCommented:
Hmmm . . . I guess I didn't cover the vbs issue huh!

Perhaps if you use a batch to "start file.vbs" it will help??
0
 
RabidSquirrelAuthor Commented:
You can do it for any DOS files... you can right click on them and there is an option to "Close on exit". Seems amazing to me that the newer command interpreter doesn't have a feature like this.
0
 
mrdtnCommented:
Yeah . . . that's what I was looking for .. but it's not there.  I eve tried creating shortcuts and doing the same.
0
 
sirbountyCommented:
Click Start->Run->Regedit
  Navigate to HKey_Classes_Root\exefile\shell\open\command
  Alter Default to read
    CMD.EXE /K "%1" %*

You'll want to repeat this little procedure for
  Navigate to HKey_Classes_Root\VBSFile\shell\open\command
  Alter its default to:
  CMD /K %SystemRoot%\System32\WScript.exe "%1" %*

~sirbounty
0
 
chadCommented:
SB,
Did I ever tell you ' you are the man!' ?
I was just experimenting with that same key ...
0
 
sirbountyCommented:
Rockanolie... :D
(Kabaam - I think you've got an auto-email to tell me that daily - can ya quit it? LOL)
0
 
chadCommented:
ok.. maybe not that exact one... but...
0
 
sirbountyConnect With a Mentor Commented:
Keep in mind RabidSquirrel, that this is not an exact solution.

Since you want IPCONFIG.EXE and your .VBS files to linger after the fact, all EXEs & VBSs will "stick around" now..
Try Start->Run->Notepad.exe and you'll see what I mean.

Unfortunately, this is the only way to effectively accomplish what you're after - thus, 'all' or 'nothing'.

Alternatively, you could try creating PIFs for each file you'd ever want to accomplish this with, or simply precede the apps you want to remain open with CMD /K in the Start/Run line (as previously mentioned).

Other 'solutions' tried include,  (If you're interested, read on...but most, if not all of these have been failed attempts)

Setting the properties of _Default.PIF and Dosex.exe to "not close on exit" - this worked in older OSs, I think - but not 2k/XP

Creating 'dummy' files for this purpose (i.e. ipconfig.bat, which would call ipconfig.exe) would work if you specified the extension (Start/Run/IPCONFIG.BAT)

But trying to 'fool' Windows would not (i.e. renaming ipconfig.exe to ipconfig.bat and ipconfig.bat to ipconfig.exe - so that the exe, which is the bat, would have the CMD /K setup and call the bat, which is the exe).  This could possibly work, if system restore was disabled, and/or the appropriate files were pulled out of the dllcache folder.

Good luck with it. :D
0
 
shaggybCommented:
you need to do a virus scan...... www.trendmicro.com   free online scan

number of times ive seen trojans r such close the system config tools    does it do the same thing with regedit?

if yes then definatly do your virus scan
0
 
RabidSquirrelAuthor Commented:
Ohhh sirbounty thats almost it! Unfortunately it does it for everything (notepad) like you said in your post after that :( You had me jumping out of my seat for a bit there though.

I'm gonna keep at this... I refuse to believe it isn't possible.
0
 
shaggybCommented:
you know after re reading your post.... i realize how rediculous my post is..... lol just ignore me on this thread...... lol
0
 
sirbountyCommented:
RabidSquirrel - that's it, I'm afraid.
Even logically speaking - how else would/could it be possible?

Either you alter this on a case-by-case basis or you config the entire EXE/VBS environment.  
How would you expect this to be selective?

There is, however, a way to turn it on and off though.

Export those two reg keys into both a 'before' and 'after' file..

Now you can create two batch files:

Turniton.bat:
-----------
@regedit /s noautoclose.reg
-----------

Turnitoff.bat
--------------
@regedit /s autoclose.reg
-------------

When you want this environment active - start->run->turniton.bat
and not, start->run->turnitoff.bat
(naturally saving these files in %systemroot%\system32)
0
 
chadCommented:
having on/off scripts would help greatly in this.  maybe have the logon script turn on and another to turn it off when not needed.
I set it on using Sirbounty's reg hack suggestion.  It did what it should.. the cmd window stayed open, but...
Problem one.... the notepad and everything else deal
problem two.... some things will not open at all with this setting.  such as the control panel applets.

so, on and off scripts would be needed
0
 
RabidSquirrelAuthor Commented:
Sorry, totally forgot about this post.

Neither answer was what I was looking for but were worth awarding points to.

sirbounty's solution was very cleaver but still had a big flaw.
mrdtn's solution is the best answer out of all of the ones I received. I find myself using this method sometimes.

Thanks to everyone for the help... even though we never found the correct answer.
0
 
PeteDCommented:
Don't know if this helps, but when I want this to happen for a paricular .bat file, I just create a shortcut to it and put the cmd /k in the target property e.g.:

cmd /k C:\SomeFolder\Release.bat
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.