# \*.rb not running on Windows any more

**URL:** <https://www.ruby-forum.com/t/rb-not-running-on-windows-any-more/99172>\
**Category:** Ruby\
**Created:** [July 20, 2006, 8:17pm UTC](https://www.ruby-forum.com/t/rb-not-running-on-windows-any-more/99172 "2006-07-20T20:17:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [July 20, 2006, 8:17pm UTC](https://www.ruby-forum.com/t/rb-not-running-on-windows-any-more/99172/1 "2006-07-20T20:17:56Z")

</div>

At work, I installed 1.8.2 from the one-click.  
I wrote a handy utility named “findfile.rb”, and put it in my  
windows\system32 directory.  
I was happy, because I could open any cmd window and type “findfile  
…” and my ruby script would kick the crap out of Windows’ built-in  
search features.

But then I installed 1.8.4 from the one-click.  
Now, when I type “findfile …” in a command window, Windows rudely  
informs me:  
“‘findfile’ is not recognized as an internal or external command,  
operable program or batch file.”

The findfile.rb file is still in the same spot.  
Ruby was installed in the same spot.  
I’ve tried associating \*.rb with c:\ruby\bin\ruby.exe and  
c:\ruby\bin\rubyw.exe, but to no avail.

Who can help me in my quest to continue to kick the crap out of  
Windows’ built-in search?

(For those interested, following is my hack script. It was originally  
written to allow regexp filename searching, and was later expanded to  
allow regexp content searching, too.)

require ‘rubygems’  
require\_gem ‘Usage’  
usage = Usage.new “name\_regexp [content\_regexp]”

class Dir  
def self.crawl( path, max\_depth=nil, depth=0, &block )  
return if max\_depth && depth \> max\_depth  
begin  
if File.directory?( path )  
files = Dir.entries( path ).select{ |f| f[0,1]!=’.’ }  
unless files.empty?  
files.collect!{ |file\_path|  
Dir.crawl( path+’/’+file\_path, max\_depth, depth+1, &block )  
}.flatten!  
end  
return files  
elsif File.file?( path )  
yield( path, depth )  
end  
rescue SystemCallError =\> the\_error  
warn “ERROR: #{the\_error}”  
end  
end

end

start\_time = Time.new  
name\_match = Regexp.new( usage.name\_regexp, true )  
content\_match = usage.content\_regexp && Regexp.new(  
“.{0,10}#{usage.content\_regexp}.+”, true )

matching\_count = 0  
Dir.crawl( ‘.’, usage.max\_depth ){ |file\_path, depth|  
if File.split( file\_path )[1] =~ name\_match  
if content\_match  
if IO.read( file\_path ) =~ content\_match  
puts file\_path," #{$~}"," "  
matching\_count += 1  
end  
else  
puts file\_path  
matching\_count += 1  
end  
end  
}  
end\_time = Time.new  
puts “(Found #{matching\_count} files in #{end\_time-start\_time} seconds)”

---

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [July 20, 2006, 9:48pm UTC](https://www.ruby-forum.com/t/rb-not-running-on-windows-any-more/99172/2 "2006-07-20T21:48:38Z")

</div>

> Who can help me in my quest to continue to kick the crap out of  
> Windows’ built-in search?

I’m guessing a bit here, but the problem might lie in the Path or  
PATHEXT environment variables, rather than Explorer’s file associations  
(which I don’t think cmd even knows about) - one or the other may have  
been modified by the 1.8.4 one-click? I’m probably embarrassingly wrong  
though, so hopefully someone else can be more helpful…

---

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [July 20, 2006, 10:01pm UTC](https://www.ruby-forum.com/t/rb-not-running-on-windows-any-more/99172/3 "2006-07-20T22:01:47Z")

</div>

Ben Z. wrote:

> I’m guessing a bit here, but the problem might lie in the Path or  
> PATHEXT environment variables

PATHEXT it was, thanks!

Now I can go back to pwning Microsoft and usage this computer in a  
moderately more reasonable fastion.
