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

</div>

Thanks, folks! By coincidence, I had just successfully wrapped the API  
call myself and was about to share the solution. Dan’s code may be  
better (I’m still learning Ruby), but I’ll go ahead and post mine below  
anyway.

Jamal

require ‘Win32API’

app = Win32API.new(“kernel32”, “GetModuleFileName”, [‘L’, ‘P’, ‘L’],  
‘L’)  
handle = 0  
size = 260  
buffer = ’ ’ \* size  
result = app.Call(handle, buffer, size)  
puts(result) # number of characters returned to buffer (20 in this case)

path = buffer.unpack(“Z\*”).to\_s # unpack to single string  
puts(path) # C:\TestRuby\ruby.exe
