Solved

Auto-Closing Command Windows, How to stop

Posted on 2004-04-14
26
2,033 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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
 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Disclosure: Use this tutorial only when no other options helps to get Windows XP running without any problems and you don't want to format the drive. The back up of the data is the responsible of the user, however there is a description of how t…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

808 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