Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

There are a number of console type applications, e.g. ipconfig, that output information to the standard output.

The problem is that if I create a windows shortcut to them it runs the command and closes the console window before I can read the output.

I realize that I could create a batch file with a pause command and then make the shortcut go to that batch file, but I was wondering if there was any generic way I could configure a shortcut to a console/command-line type program to leave the window open until the user explicitly closes it.

share|improve this question
    
stackoverflow.com/a/13746246/447599 – Julius Nov 27 '14 at 17:26
up vote 7 down vote accepted

Use cmd.exe

cmd /k ipconfig
cmd /k ping google.com
cmd /k etc..........

command line does NOT go away until you exit it.

share|improve this answer
    
Tough to pick a winner on this one because all of these answers work, but I'm going with this one because it is the simplest of the approaches offered. – JohnFx Aug 13 '10 at 15:26
    
@JohnFx: In the meanwhile there is a better solution which is just as simple. – oberlies Nov 7 '13 at 14:50

Probably you can't. I thought there was an option to set, but on Windows Seven, I cannot find anything like this.

Like you said, the easiest way is to make a batch file. Note that you can make it perfectly generic. Create a file generic.bat containing:

%1
pause

then call it with a shortcut:

generic.bat ipconfig
share|improve this answer
    
That's a really good idea! – JohnFx Aug 13 '10 at 15:24

Alternatively, you can use the /c option with cmd.exe like so:

%COMSPEC% /c ipconfig&&pause
share|improve this answer
    
IMHO the best solution, but doesn't work if the first command signals an error (through a non-zero exit code). This only works when using a single ampersand: %COMSPEC% /c <command> & pause – oberlies Nov 7 '13 at 14:48
    
Anyone wondering why you need cmd /c: to interpret the & syntax. The standard Windows shortcut is not a command line so we need to wrap it. – TWiStErRob Jun 27 '15 at 11:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .