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

I hope I am missing something blindingly obvious here, but I can't get things I run from the command window to stay open.

That is, 1. I open a new command prompt (windows key + r) + "cmd" 2. I try any of the possibilities in my question below in the resulting window 3. A new ruby window opens and then closes and I can't see any of the output

For example, I am trying to write some ruby code and run rspec. However, I have tried

  • rspec
  • cmd /k rspec
  • start /B rspec
  • from run menu: cmd rspec (rspec doesn't even run)

Each time the window closes as soon as it finishes executing. It would be great if it just executed in the same window I had open and stayed open.

Is there some kind of setting I am missing here?

As a workaround I can run irb and then use the back-tick method like so


And that runs well - the output persists onscreen and I can keep working. But this is really painful. It was much easier in Windows XP and I find it difficult to believe that Windows 7 can't support something similar.

share|improve this question
I don't "do" Windows, but surely the solution would be to run just "cmd", and then run "rspec" in the command prompt box ? – davidgo Mar 11 '13 at 8:26
afraid that doesn't work. Hopefully my update makes it clearer – JoeyC Mar 11 '13 at 22:49
up vote 3 down vote accepted

Type cmd in the Start Menu search box, right-click cmd.exe, click Run as administrator, select Yes in the UAC dialog and enter your admin password if prompted.

This opens an elevated command prompt. Now run your Ruby commands as usual.

share|improve this answer
Hell yeah! That worked. Thx :) – JoeyC Mar 11 '13 at 23:22
You're welcome. :) Guess whatever program you were running required elevation. You can generally know this is the case if the EXE has the blue and yellow shield on its icon. You can also create an admin mode command prompt shortcut as detailed here. – Karan Mar 11 '13 at 23:23
You can also use the keyboard shortcut Ctrl+Shift+Enter to launch the selected program as Administrator from the start menu. Saves you from having to use the mouse. – Dracs Mar 12 '13 at 1:42
@Dracs: Yes, or Ctrl+Shift+Left_click too if a keyboard+mouse combo interests you! I use a keyboard shortcut for my elevated command prompt shortcut anyway, and the Task Scheduler trick can also be used to suppress the UAC prompt. – Karan Mar 12 '13 at 1:54

There's no reason why it wouldn't work the same way in Windows 7 - I suspect it will be down to permissions or similar.

Create a batch file - say 'runrspec.bat'

In there put your rspec command, and on the next line put 'pause'.

Then run the .bat file instead of rspec. The pause command will stop the window closing until you press a key, so you can see any error that is being thrown up.

share|improve this answer

The problem is you're executing this from the run command. This means as soon as the program finishes the console window closes (since you've not explicitly called for the console window).

In the search box of the start menu (or click All Programs -> Accessories -> Command Prompt), type in CMD and press enter to bring up console window. Now type in your commands (eg rspec)

share|improve this answer
Thanks for trying but it doesn't work. I have added it to my list of things I tried in the question – JoeyC Mar 11 '13 at 8:49
@JoeyC Please open the command prompt from All Programs -> Accessories -> Command Prompt then type in ping and press enter - Does the screen close automatically – Dave Mar 11 '13 at 8:50
@JoeyC: What doesn't work? Nowhere in your updated question do I see where you have run cmd first and then executed rspec at the command prompt. – Karan Mar 11 '13 at 18:21
@DaveRook - unfortunately, I can't find command prompt anywhere - its not in accessories, or if I try searching from "Search Programs or Files" box from start menu – JoeyC Mar 11 '13 at 22:47
WinKey - R will bring up the "Run" window, try typing "CMD" in there and pressing enter. That should bring up a command prompt window as well. – MikeAWood Mar 11 '13 at 22:55

You must log in to answer this question.

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