Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

win32ole

Status
Not open for further replies.

yeungsprite

Programmer
Nov 28, 2002
25
US
Hello, I am new to Ruby and Windows programming and have a question regarding the WIN32OLE. The following sample code is used to launch MS Internet Explorer.

require 'win32ole'
ie = WIN32OLE.new('InternetExplorer.Application')
ie.visible = true
ie.gohome

What I would like to do is launch MS Windows Explorer (file manager / Windows GUI Shell) and determine the functions to call to traverse it (ie expand branches, open files, etc) for automation purposes.

Can anyone suggest resources on how to accomplish this?

Thanks very much!


 
I think one would rather use WSH (Windows Scripting Host) for such things:
WSHShell = WIN32OLE.new("WScript.Shell")

You may also use the FileSystemObject:
FSO = WIN32OLE.new("Scripting.FileSystemObject")

The closest to your idea is
wshell = WIN32OLE.new("Shell.Application")

This does not only create a windows explorer, but a shell.
wshell.Explore("C:") would then create a windows explorer displaying the C: drive.

I'm sure you'll find lots of stuff about these COM classes at Microsoft. Also consider WMI (Windows Management Instrumentation).

Bye, Olaf.
 
I found a simpler way using AutoItX3, which is a freeware automation tool that comes with a combined DLL/COM module called AutoItX with a separate HTML help file describing clearly the COM methods available.


Here's the Ruby code now:

require 'win32ole'

a3 = WIN32OLE.new("AutoItX3.Control")
a3.Run("explorer.exe")
 
Hi yeungsprite,

Such an automation tool may not be the best idea regarding security issues. You'd normally run a server without any user logged in, only services running, like sql server or iis to name just two complexer services.

From what I read about Autoit, that tool does not run as a service, does it? It automates windows by simulating user interaction and so applications really are run and used and you can see the action on the desktop. It may be very intuitive and okay for desktops, but not for a server.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top