Associating .rb files with Ruby in Windows

DOS 3.3 - Old Skool Apple 2

Today I had to write a DOS batch file to automate something on my Windows laptop. Unfortunately (fortunately?) I’ve forgotten the DOS batch language years ago. After giving it the old college try for 15 minutes, I thought I would give ruby a go since it was already on my system in the form of InstantRails.

The first issue was that none of the .rb files that I made would get noticed by ruby. After typing “start script.rb”, I found that I could associate the file with the ruby.exe in the \InstantRails\ directory. Then the next problem occurred. For some unknown reason, the arguments to the script were not making it into ARGV in the ruby script.

After a bunch of searching, I found a wikibook that had the answer at the bottom.

$ assoc .rb=RubyScript .rb=RubyScript

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

For more info, go to the wiki book. I’m sure this is useful for other scripting languages as well.

This entry was posted in General. Bookmark the permalink.

Leave a Reply

Your email address will not be published.