Why does the command window always disappear right away on Windows 7?

37,937

Solution 1

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.

Solution 2

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:
37,937

Related videos on Youtube

JoeyC
Author by

JoeyC

Updated on September 18, 2022

Comments

  • JoeyC
    JoeyC over 1 year

    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

    `rspec`
    

    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.

    • davidgo
      davidgo about 11 years
      I don't "do" Windows, but surely the solution would be to run just "cmd", and then run "rspec" in the command prompt box ?
    • JoeyC
      JoeyC about 11 years
      afraid that doesn't work. Hopefully my update makes it clearer
  • JoeyC
    JoeyC about 11 years
    Thanks for trying but it doesn't work. I have added it to my list of things I tried in the question
  • Karan
    Karan about 11 years
    @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.
  • JoeyC
    JoeyC about 11 years
    @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
    JoeyC about 11 years
    @Karan thanks for the feedback. I have added some extra info which hopefully makes it clearer.
  • MikeAWood
    MikeAWood about 11 years
    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.
  • JoeyC
    JoeyC about 11 years
    Hell yeah! That worked. Thx :)
  • Karan
    Karan about 11 years
    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.
  • Dracs
    Dracs about 11 years
    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.
  • Karan
    Karan about 11 years
    @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.