# Re: Full paths of Ruby interpreter and running script

**URL:** <https://www.ruby-forum.com/t/re-full-paths-of-ruby-interpreter-and-running-script/94000>\
**Category:** Ruby\
**Created:** [April 17, 2006, 9:50pm UTC](https://www.ruby-forum.com/t/re-full-paths-of-ruby-interpreter-and-running-script/94000 "2006-04-17T21:50:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamal86](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ebca7d/32.png) [@jamal86](https://www.ruby-forum.com/u/jamal86)\
**Post date:** [April 17, 2006, 9:50pm UTC](https://www.ruby-forum.com/t/re-full-paths-of-ruby-interpreter-and-running-script/94000/1 "2006-04-17T21:50:25Z")

</div>

I appreciate these suggestions, but found that they do not actually  
solve my problem. If a full Ruby installation is done with the One  
Click Installer, the code does return the folder containing the Ruby  
interpreter (C:\Ruby\bin by default). In distributing a Ruby program I  
am developing, however, I intend to distribute only the minimum set of  
files for running the program. Through trial and error, I have found  
that these are ruby.exe, msvcrt-ruby18.dll, and the particular .so or  
.rb library files that my main script.rb file calls.

In testing the rbconfig technique, I copied these files, including  
rbconfig.rb, into a temporary folder, c:\TestRuby. When I ran a test  
program at the command prompt, the correct path was not given. It  
should have been C:\TestRuby\rubyw.exe for the interpreter (or  
C:\TestRuby\test.rb for the script file).

Windows has an API function, GetModuleFileName , that returns the full  
path of the running executable. I may be able to wrap an API call using  
the Win32API library, but prefer a native Ruby approach if possible.

Jamal

---

<div class="post-metadata">

**Author:** ![jamal86](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ebca7d/32.png) [@jamal86](https://www.ruby-forum.com/u/jamal86)\
**Post date:** [April 17, 2006, 10:15pm UTC](https://www.ruby-forum.com/t/re-full-paths-of-ruby-interpreter-and-running-script/94000/2 "2006-04-17T22:15:49Z")

</div>

On Tue, 18 Apr 2006, Jamal M. wrote:

> rbconfig.rb, into a temporary folder, c:\TestRuby. When I ran a test  
> program at the command prompt, the correct path was not given. It  
> should have been C:\TestRuby\rubyw.exe for the interpreter (or  
> C:\TestRuby\test.rb for the script file).
> 
> Windows has an API function, GetModuleFileName , that returns the full  
> path of the running executable. I may be able to wrap an API call using  
> the Win32API library, but prefer a native Ruby approach if possible.
> 
> Jamal

check out dl - you can’t make native calls directory. of course you  
also have  
the win32 api in ruby…

either should give you what you want.

-a
