Solved

Auto-Closing Command Windows, How to stop

Posted on 2004-04-14
26
2,030 Views
Last Modified: 2007-12-19
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?
0
Comment
Question by:RabidSquirrel
  • 7
  • 6
  • 4
  • +4
26 Comments
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 10829391
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
 

Author Comment

by:RabidSquirrel
ID: 10829401
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
 
LVL 6

Expert Comment

by:mrdtn
ID: 10829409
This is what you need to do:

Use:

cmd /k ipconfig

instead of what you were doing.

Same for the other commands.

--

mrdtn
0
 
LVL 6

Accepted Solution

by:
mrdtn earned 250 total points
ID: 10829419
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
 

Author Comment

by:RabidSquirrel
ID: 10829423
That does nothing for my batch files and vbs files that I wish to double-click
0
 
LVL 6

Expert Comment

by:mrdtn
ID: 10829441
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
 
LVL 11

Expert Comment

by:kabaam
ID: 10829447
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
 

Author Comment

by:RabidSquirrel
ID: 10829473
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
 
LVL 6

Expert Comment

by:mrdtn
ID: 10829513
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
 
LVL 6

Expert Comment

by:mrdtn
ID: 10829522
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
 
LVL 6

Expert Comment

by:mrdtn
ID: 10829529
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
 

Author Comment

by:RabidSquirrel
ID: 10829534
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 6

Expert Comment

by:mrdtn
ID: 10829580
Yeah . . . that's what I was looking for .. but it's not there.  I eve tried creating shortcuts and doing the same.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 10829626
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
 
LVL 11

Expert Comment

by:kabaam
ID: 10829648
SB,
Did I ever tell you ' you are the man!' ?
I was just experimenting with that same key ...
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 10829656
Rockanolie... :D
(Kabaam - I think you've got an auto-email to tell me that daily - can ya quit it? LOL)
0
 
LVL 11

Expert Comment

by:kabaam
ID: 10829667
ok.. maybe not that exact one... but...
0
 
LVL 67

Assisted Solution

by:sirbounty
sirbounty earned 250 total points
ID: 10829730
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
 
LVL 3

Expert Comment

by:shaggyb
ID: 10829816
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
 

Author Comment

by:RabidSquirrel
ID: 10830348
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
 
LVL 3

Expert Comment

by:shaggyb
ID: 10830657
you know after re reading your post.... i realize how rediculous my post is..... lol just ignore me on this thread...... lol
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 10831525
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
 
LVL 11

Expert Comment

by:kabaam
ID: 10834648
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
 

Author Comment

by:RabidSquirrel
ID: 11065058
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
 
LVL 2

Expert Comment

by:PeteD
ID: 11330268
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

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Most of the time we are in fix when all of sudden our systems behave weirdly.  Such problems cost time and effort... so it's best to take some preventive actions so that we can avoid such issues or overcome such problems more easily. Preventive M…
If you have done a reformat of your hard drive and proceeded to do a successful Windows XP installation, you may notice that a choice between two operating systems when you start up the machine. Here is how to get rid of this: Click Start Clic…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

757 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

18 Experts available now in Live!

Get 1:1 Help Now