# 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/94003>\
**Category:** Ruby\
**Created:** [April 17, 2006, 10:31pm UTC](https://www.ruby-forum.com/t/re-full-paths-of-ruby-interpreter-and-running-script/94003 "2006-04-17T22:31:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BergerS\_Daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc8723/32.png) [@BergerS\_Daniel](https://www.ruby-forum.com/u/BergerS_Daniel)\
**Post date:** [April 17, 2006, 10:31pm UTC](https://www.ruby-forum.com/t/re-full-paths-of-ruby-interpreter-and-running-script/94003/1 "2006-04-17T22:31:29Z")

</div>

> -----Original Message-----  
> From: Jamal M. [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
> Sent: Monday, April 17, 2006 1:47 PM  
> To: ruby-talk ML  
> Subject: Re: Full paths of Ruby interpreter and running script

> 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

Yep, that’ll work. For anyone who’s curious:

require ‘Win32API’

buf = 0.chr \* 260  
GetModuleFileName = Win32API.new(‘kernel32’, ‘GetModuleFileName’, ‘LPL’,  
‘L’)

GetModuleFileName.call(0, buf, buf.size)  
puts buf.strip # “c:\ruby\bin\ruby.exe”

That being said, I _thought_ there was a way to do this from within Ruby  
(without resorting to Win32API) but I can’t think of it now, assuming it  
exists.

Regards,

Dan
