0

Possible Duplicate:
How to I launch a ruby script from the command line by just its name?

Currently I am using:

ruby test.rb

But want to run it on command prompt as:

test

How could I do that?

Community
  • 1
  • 1
Suyog Sakegaonkar
  • 225
  • 2
  • 10
  • 21
  • http://stackoverflow.com/questions/1422380/how-to-i-launch-a-ruby-script-from-the-command-line-by-just-its-name – Anand Shah Jan 16 '13 at 11:27
  • dublicated question (@Anand link) and also http://superuser.com/questions/373706/how-can-i-run-a-shell-script-in-windows – CodeGroover Jan 16 '13 at 11:41

2 Answers2

1

Follow the instructions available here:

  1. Log in as an administrator.
  2. Run the standard Windows "Command Prompt", cmd.
  3. At the command prompt (i.e. shell prompt), run the following Windows commands. When you run ftype, change the command-line arguments to correctly point to where you installed the ruby.exe executable on your computer.

    $ assoc .rb=RubyScript

    .rb=RubyScript

    $ ftype RubyScript="c:\ruby\bin\ruby.exe" "%1" %*

    RubyScript="c:\ruby\bin\ruby.exe" "%1" %*

Glauco Vinicius
  • 2,527
  • 3
  • 24
  • 37
0

You can make your .rb files open with ruby interpreter.

  • Right click on any .rb file
  • Select 'Open With'
  • Browse to bin folder in your ruby directory (wherever you installed it. C:\Programs Files?)
  • Choose 'ruby' (and not 'rubyw')
  • Do remember to tick the checkbox 'Always use this program to open files of this type'

All done. Now you can run scripts using just their names. Alternatively, you can also run them by simply double clicking.

Akash
  • 5,153
  • 3
  • 26
  • 42