# Invoking a windows application (e.g notepad) from ruby

**URL:** <https://www.ruby-forum.com/t/invoking-a-windows-application-e-g-notepad-from-ruby/132418>\
**Category:** Ruby\
**Created:** [March 19, 2008, 11:42pm UTC](https://www.ruby-forum.com/t/invoking-a-windows-application-e-g-notepad-from-ruby/132418 "2008-03-19T23:42:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anukulsinghal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/dbc845/32.png) [@anukulsinghal](https://www.ruby-forum.com/u/anukulsinghal)\
**Post date:** [March 19, 2008, 11:42pm UTC](https://www.ruby-forum.com/t/invoking-a-windows-application-e-g-notepad-from-ruby/132418/1 "2008-03-19T23:42:03Z")

</div>

Hi,

I wanted to know if there is any utility present in ruby through which  
we can invoke an external windows app (notepad.exe) or any exe.

Can anyone please help me with the relevant code in ruby which can do  
so?

Thanks,  
Anukul

---

<div class="post-metadata">

**Author:** ![anukulsinghal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/dbc845/32.png) [@anukulsinghal](https://www.ruby-forum.com/u/anukulsinghal)\
**Post date:** [March 20, 2008, 12:06am UTC](https://www.ruby-forum.com/t/invoking-a-windows-application-e-g-notepad-from-ruby/132418/2 "2008-03-20T00:06:58Z")

</div>

Anukul S. wrote:

> Hi,
> 
> I wanted to know if there is any utility present in ruby through which  
> we can invoke an external windows app (notepad.exe) or any exe.
> 
> Can anyone please help me with the relevant code in ruby which can do  
> so?
> 
> Thanks,  
> Anukul

The short way:

`notepad`

Note these are backticks, not single quotes. Ruby will wait until  
notepad is finished. If the waiting is not desired, this is an option:

system(“start notepad”)  
system(“calc”)

Possibly you have to provide the full path to the executable.

Regards,

Siep

---

<div class="post-metadata">

**Author:** ![anukulsinghal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/dbc845/32.png) [@anukulsinghal](https://www.ruby-forum.com/u/anukulsinghal)\
**Post date:** [March 20, 2008, 12:12am UTC](https://www.ruby-forum.com/t/invoking-a-windows-application-e-g-notepad-from-ruby/132418/3 "2008-03-20T00:12:33Z")

</div>

On Wed, Mar 19, 2008 at 11:42 PM, Anukul S.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi,
> 
> I wanted to know if there is any utility present in ruby through which  
> we can invoke an external windows app (notepad.exe) or any exe.
> 
> Can anyone please help me with the relevant code in ruby which can do  
> so?

if you want to wait until the program finishes:  
system “notepad”  
if you don’t want:  
system “start notepad”

see also Kernel#`

note that if you need to quote the program name, you have to add  
another pair of quotes, because start  
threats the first quoted string as window title.

system ‘start “” “C:\Program Files\whaterver.exe”’

---

<div class="post-metadata">

**Author:** ![anukulsinghal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/dbc845/32.png) [@anukulsinghal](https://www.ruby-forum.com/u/anukulsinghal)\
**Post date:** [March 20, 2008, 8:02am UTC](https://www.ruby-forum.com/t/invoking-a-windows-application-e-g-notepad-from-ruby/132418/4 "2008-03-20T08:02:10Z")

</div>

Jano S. wrote:

> On Wed, Mar 19, 2008 at 11:42 PM, Anukul S.  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Hi,
> > 
> > I wanted to know if there is any utility present in ruby through which  
> > we can invoke an external windows app (notepad.exe) or any exe.
> > 
> > Can anyone please help me with the relevant code in ruby which can do  
> > so?
> 
> if you want to wait until the program finishes:  
> system “notepad”  
> if you don’t want:  
> system “start notepad”
> 
> see also Kernel#`
> 
> note that if you need to quote the program name, you have to add  
> another pair of quotes, because start  
> threats the first quoted string as window title.
> 
> system ‘start “” “C:\Program Files\whaterver.exe”’

* * *

Jano, thanks a lot!

…Anukul

---

<div class="post-metadata">

**Author:** ![anukulsinghal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/dbc845/32.png) [@anukulsinghal](https://www.ruby-forum.com/u/anukulsinghal)\
**Post date:** [March 20, 2008, 8:01am UTC](https://www.ruby-forum.com/t/invoking-a-windows-application-e-g-notepad-from-ruby/132418/5 "2008-03-20T08:01:14Z")

</div>

Siep K. wrote:

> Anukul S. wrote:
> 
> > Hi,
> > 
> > I wanted to know if there is any utility present in ruby through which  
> > we can invoke an external windows app (notepad.exe) or any exe.
> > 
> > Can anyone please help me with the relevant code in ruby which can do  
> > so?
> > 
> > Thanks,  
> > Anukul
> 
> The short way:
> 
> `notepad`
> 
> Note these are backticks, not single quotes. Ruby will wait until  
> notepad is finished. If the waiting is not desired, this is an option:
> 
> system(“start notepad”)  
> system(“calc”)
> 
> Possibly you have to provide the full path to the executable.
> 
> Regards,
> 
> Siep

* * *

Siep, Thanks a lot!!

…Anukul
