Using Win32OLE, WMI and ExecMethod

Discussion in 'Ruby' started by Daniel Berger, Jun 3, 2004.

  1. Hi all,

    Ruby 1.8.1
    Windows 2000

    I'm playing with WMI to control services via Ruby. I can list
    services easily enough with InstancesOf(), but how do I call methods
    on a class?

    I tried something like this, but this is clearly illegal. Can someone
    provide me with the right way to do what I'm trying to do here?

    require "win32ole"
    wmi = WIN32OLE.connect("winmgmts://")
    wmi.ExecMethod("Win32_Service","StartService","ClipSrv") # Illegal

    I've tried various connect strings and done some futzing, but no luck.
    Please help. Thanks.

    Dan
    Daniel Berger, Jun 3, 2004
    #1
    1. Advertising

  2. (Daniel Berger) wrote in message news:<>...
    > Hi all,
    >
    > Ruby 1.8.1
    > Windows 2000
    >
    > I'm playing with WMI to control services via Ruby. I can list
    > services easily enough with InstancesOf(), but how do I call methods
    > on a class?
    >
    > I tried something like this, but this is clearly illegal. Can someone
    > provide me with the right way to do what I'm trying to do here?
    >
    > require "win32ole"
    > wmi = WIN32OLE.connect("winmgmts://")
    > wmi.ExecMethod("Win32_Service","StartService","ClipSrv") # Illegal
    >
    > I've tried various connect strings and done some futzing, but no luck.
    > Please help. Thanks.
    >
    > Dan


    Never mind. It appears that you call the method on an instance within
    an each block. Still, I think some form of ExecMethod ought to work.

    Regards,

    Dan
    Daniel Berger, Jun 4, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Daniel Berger

    Segfault with win32ole, WMI and structs

    Daniel Berger, May 23, 2004, in forum: Ruby
    Replies:
    4
    Views:
    147
    Jos Backus
    May 24, 2004
  2. Masaki Suketa
    Replies:
    4
    Views:
    372
    Dave Burt
    Mar 27, 2006
  3. Spike

    WMI and WIN32OLE issues

    Spike, Oct 26, 2006, in forum: Ruby
    Replies:
    0
    Views:
    85
    Spike
    Oct 26, 2006
  4. Barrie Hill

    win32ole and WMI question

    Barrie Hill, Jan 3, 2009, in forum: Ruby
    Replies:
    2
    Views:
    155
    Barrie Hill
    Jan 3, 2009
  5. Daniel Berger

    OLE, WMI and ExecMethod - possible?

    Daniel Berger, Jun 15, 2004, in forum: Perl Misc
    Replies:
    1
    Views:
    233
    Petri
    Jun 15, 2004
Loading...

Share This Page