# Windows Automation

**URL:** <https://rubytalk.org/t/windows-automation/52464>\
**Category:** ruby-talk\
**Created:** [24 March 2009 02:38 UTC](https://rubytalk.org/t/windows-automation/52464 "2009-03-24T02:38:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![M\_C](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@M\_C](https://rubytalk.org/u/M_C)\
**Post date:** [24 March 2009 02:38 UTC](https://rubytalk.org/t/windows-automation/52464/1 "2009-03-24T02:38:54Z")

</div>

So, I'm trying to figure out how to automate various programs using  
ruby, and feeling a bit over my head at the moment. I'm still pretty  
new to ruby and programming, so maybe this is beyond me, but its the #1  
reason I decided to learn ruby in the first place.

What I'm wondering is...where to start? I believe I'm right in the fact  
that I need to be using WIN32OLE, but beyond that I can't seem to get  
anywhere.

How do you determine what the exact name of the program is that you need  
to pass as a parameter when creating a new WIN32OLE  
object('WhatProgramNameHere.Application')? How do you find what methods  
can be used with that specific program? Am I even right in assuming I  
should be using WIN32OLE? If someone would be so kind as to steer me in  
the right direction with some tips or reading material I'd be eternally  
grateful. 🙂

Thanks for reading,  
Marc

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Charles\_Calvert](https://avatars.discourse-cdn.com/v4/letter/c/e19b73/32.png) [@Charles\_Calvert](https://rubytalk.org/u/Charles_Calvert)\
**Post date:** [24 March 2009 22:16 UTC](https://rubytalk.org/t/windows-automation/52464/2 "2009-03-24T22:16:53Z")

</div>

wrote in \<cf299a71d3bf68781fe420e8b308759a@ruby-forum.com\>:

[snip]

> How do you determine what the exact name of the program is that you need  
> to pass as a parameter when creating a new WIN32OLE  
> object('WhatProgramNameHere.Application')? How do you find what methods  
> can be used with that specific program? Am I even right in assuming I  
> should be using WIN32OLE?

I don't know if there are any alternatives, but for automation on  
Windows, OLE is the way to go.

As for information, you're looking for OLE interface documentation. If  
you want it for Microsoft applications, then look at the MSDN  
documentation at \<[Microsoft Learn: Build skills that open doors in your career](http://msdn.microsoft.com/&gt;%5C). For example, if you  
wanted to automate Outlook 2007, you would look at  
\<[Microsoft Learn: Build skills that open doors in your career](http://msdn.microsoft.com/en-us/library/bb176619.aspx&gt;%5C). Note that  
when you search for said documentation on MSDN, use the search phrase  
"FOO object model" where FOO is the name of the application.

If you're trying to automate a nonMS application, then you'll need to  
check the documentation for the application.

If you didn't know, you can only automate applications with OLE if  
they expose an OLE interface. Those that don't may support DDE  
([http://en.wikipedia.org/wiki/Dynamic\_Data\_Exchange\](http://en.wikipedia.org/wiki/Dynamic_Data_Exchange%5C)).

> **···**
>
> On Mon, 23 Mar 2009 21:38:54 -0500, Marc Ch \<wooingruby@gmail.com\>
> 
> --  
> Charles Calvert | Web-site Design/Development  
> Celtic Wolf, Inc. | Software Design/Development  
> [http://www.celticwolf.com/](http://www.celticwolf.com/) | Data Conversion  
> (703) 580-0210 | Project Management

---

<div class="post-metadata">

**Author:** ![David\_Mullet](https://avatars.discourse-cdn.com/v4/letter/d/779978/32.png) [@David\_Mullet](https://rubytalk.org/u/David_Mullet)\
**Post date:** [25 March 2009 01:29 UTC](https://rubytalk.org/t/windows-automation/52464/3 "2009-03-25T01:29:10Z")

</div>

Marc Ch wrote:

> So, I'm trying to figure out how to automate various programs using  
> ruby, and feeling a bit over my head at the moment. I'm still pretty  
> new to ruby and programming, so maybe this is beyond me, but its the #1  
> reason I decided to learn ruby in the first place.
> 
> What I'm wondering is...where to start? I believe I'm right in the fact  
> that I need to be using WIN32OLE, but beyond that I can't seem to get  
> anywhere.
> 
> How do you determine what the exact name of the program is that you need  
> to pass as a parameter when creating a new WIN32OLE  
> object('WhatProgramNameHere.Application')? How do you find what methods  
> can be used with that specific program? Am I even right in assuming I  
> should be using WIN32OLE? If someone would be so kind as to steer me in  
> the right direction with some tips or reading material I'd be eternally  
> grateful. 🙂
> 
> Thanks for reading,  
> Marc

In addition to Charles' recommendations, you'll find a lot regarding  
Windows automation on my "Ruby on Windows" blog:

&nbsp;&nbsp;[http://rubyonwindows.blogspot.com](http://rubyonwindows.blogspot.com)

David

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![M\_C](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@M\_C](https://rubytalk.org/u/M_C)\
**Post date:** [26 March 2009 21:20 UTC](https://rubytalk.org/t/windows-automation/52464/4 "2009-03-26T21:20:39Z")

</div>

Thanks for the replies; very useful stuff. Maybe I'm blind, but I've  
been crawling through the MSDN documentation for help with iexpress, and  
I can't seem to figure out what its object is called. The best I can  
find is a list of what command line switches/options it supports  
([http://technet.microsoft.com/en-us/library/bb496369.aspx](http://technet.microsoft.com/en-us/library/bb496369.aspx)).

I've tried just guessing a large variety of obvious names for it as  
well, but that doesn't seem to do anything but make me want to slam my  
face against a rock. 😉 If I'm completely overlooking it, can someone  
point it out for me?

I did find, thanks to David's blog, that I can start it up without OLE  
using system('iexpress') but I haven't yet been able to succesfully make  
use of the defined command line options with that.

Not sure which way is best, but if anyone can help out with either/both  
that'd be awesome.

Thanks,  
Marc

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Charles\_Calvert](https://avatars.discourse-cdn.com/v4/letter/c/e19b73/32.png) [@Charles\_Calvert](https://rubytalk.org/u/Charles_Calvert)\
**Post date:** [23 May 2009 14:50 UTC](https://rubytalk.org/t/windows-automation/52464/5 "2009-05-23T14:50:06Z")

</div>

wrote in \<71558ab1e7dee6bafba69ea693749fc0@ruby-forum.com\>:

> Thanks for the replies; very useful stuff. Maybe I'm blind, but I've  
> been crawling through the MSDN documentation for help with iexpress, and  
> I can't seem to figure out what its object is called. The best I can  
> find is a list of what command line switches/options it supports  
> ([IExpress Setup Options | Microsoft Learn](http://technet.microsoft.com/en-us/library/bb496369.aspx%5C)).

I suspect that it doesn't expose and OLE interface. Many of  
Microsoft's applications don't. Building such an interface is time  
consuming and costly, and I doubt they'd bother for something like  
that.

Googling didn't turn up anything, so I suspect that you're out of  
luck.

> **···**
>
> On Thu, 26 Mar 2009 16:20:39 -0500, Marc Ch \<wooingruby@gmail.com\>
> 
> --  
> Charles Calvert | Web-site Design/Development  
> Celtic Wolf, Inc. | Software Design/Development  
> [http://www.celticwolf.com/](http://www.celticwolf.com/) | Data Conversion  
> (703) 580-0210 | Project Management

---

<div class="post-metadata">

**Author:** ![Caleb\_Clausen1](https://avatars.discourse-cdn.com/v4/letter/c/8dc957/32.png) [@Caleb\_Clausen1](https://rubytalk.org/u/Caleb_Clausen1)\
**Post date:** [23 May 2009 16:07 UTC](https://rubytalk.org/t/windows-automation/52464/6 "2009-05-23T16:07:14Z")

</div>

Kernel#system works the same on windows and unix. Command line options  
are given after the name of the program you want to run, separated by  
a space. So, to start iexpress in quiet mode, try system('iexpress  
/Q'). Alternately, you can pass each option in a separate string:  
system('iexpress','/Q','/R:A') starts it in quiet mode and forces a  
restart when iexpress exits.

> **···**
>
> On 3/26/09, Marc Ch \<wooingruby@gmail.com\> wrote:
> 
> > I did find, thanks to David's blog, that I can start it up without OLE  
> > using system('iexpress') but I haven't yet been able to succesfully make  
> > use of the defined command line options with that.

---

<div class="post-metadata">

**Author:** ![Bosko\_Ivanisevic](https://avatars.discourse-cdn.com/v4/letter/b/43a26b/32.png) [@Bosko\_Ivanisevic](https://rubytalk.org/u/Bosko_Ivanisevic)\
**Post date:** [23 May 2009 16:40 UTC](https://rubytalk.org/t/windows-automation/52464/7 "2009-05-23T16:40:06Z")

</div>

I also doubt iexpress has OLE interface. Anyway if you are interested  
in using Ruby for automation on Windows you can read my article about  
MS Office automation I recently had to deal with on  
[http://pragmaticdevnotes.wordpress.com/2008/12/17/with-a-little-help-from-ruby/\](http://pragmaticdevnotes.wordpress.com/2008/12/17/with-a-little-help-from-ruby/%5C).  
Unfortunately I forgot to list some tools that can be useful for such  
a tasks and the main one is:

[http://homepage1.nifty.com/markey/ruby/win32ole/soleb-0.0.1a.zip](http://homepage1.nifty.com/markey/ruby/win32ole/soleb-0.0.1a.zip)

With it you can browse all OLE objects registered on your system, see  
their methods, properties and some other things. You should start it  
and check whether iexpress has registered some OLE interfaces at all.  
Besides you can examine code and see how you can get information about  
OLE methods and their arguments, OLE properties, etc.

Regards,  
Boško Ivanišević

> **···**
>
> On May 23, 4:45 pm, Charles Calvert \<cb...@yahoo.com\> wrote:
> 
> > On Thu, 26 Mar 2009 16:20:39 -0500, Marc Ch \<wooingr...@gmail.com\>  
> > wrote in \<71558ab1e7dee6bafba69ea693749...@ruby-forum.com\>:
> > 
> > \>Thanks for the replies; very useful stuff. Maybe I'm blind, but I've  
> > \>been crawling through the MSDN documentation for help with iexpress, and  
> > \>I can't seem to figure out what its object is called. The best I can  
> > \>find is a list of what command line switches/options it supports  
> > \>([IExpress Setup Options | Microsoft Learn](http://technet.microsoft.com/en-us/library/bb496369.aspx%5C)).
> > 
> > I suspect that it doesn't expose and OLE interface. Many of  
> > Microsoft's applications don't. Building such an interface is time  
> > consuming and costly, and I doubt they'd bother for something like  
> > that.
> > 
> > Googling didn't turn up anything, so I suspect that you're out of  
> > luck.
