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

A

Anukul Singhal

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
 
S

Siep Korteling

Anukul said:
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
 
J

Jano Svitok

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"'
 
A

Anukul Singhal

Siep said:
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
 
A

Anukul Singhal

Jano said:
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"'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,999
Messages
2,570,246
Members
46,839
Latest member
MartinaBur

Latest Threads

Top