On windows, I can run my ruby script like this:
> ruby myscript.rb
but I want to set things up so that I can just do this instead?..
> myscript.rb
How do I do this? I know it's possible because I've recently moved from one PC that had this set up to a new PC that doesn't (yet).
Associate the ".rb" file extension with the ruby interpreter. On Windows XP, one way to do this is to select "Tools|Folder options" in the file explorer, and to setup the association in the "File types" tab.
Another way would be to enter the following on the commandline which creates this file association for you:
assoc .rb=RubyScript ftype RubyScript=ruby.exe %1 %*
Read the bottom part of Wikipedia Ruby.
Windows
If you install the native Windows version of Ruby using the Ruby One-Click Installer, then the installer has setup Windows to automatically recognize your Ruby scripts as executables. Just type the name of the script to run it.
$ hello-world.rb Hello world
If this does not work, or if you installed Ruby in some other way, follow these steps.
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" %*
For more help with these commands, run "help assoc" and "help ftype".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With