How to Continue with a WMI Script on an RPC Error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anonymous
    Banned
    New Member
    • Sep 2005
    • 99

    #1

    How to Continue with a WMI Script on an RPC Error

    Python 2.5
    wmi.py 1.3

    Hello,

    I am trying to write a script that will change the properties of a service on a list of remote machines. Their online status will vary. If I create a list with computers that are not currently online, I get the following when trying to call the wmi.WMI function:

    Here is the code:

    computernames = ["computer1" , "computer2" , "computer3"]
    for x in computernames:
    c = wmi.WMI (x)
    for service in c.Win32_Service (Name="service" ):
    a = service.ChangeS tartMode (StartMode="Man ual")

    Here is the error:

    Traceback (most recent call last):
    File "C:\Python25\sr c\changeservice .py", line 5, in <module>
    c = wmi.WMI (x)
    File "C:\Python25\sr c\wmi.py", line 1124, in connect
    handle_com_erro r (error_info)
    File "C:\Python25\sr c\wmi.py", line 188, in handle_com_erro r
    raise x_wmi, "\n".join (exception_stri ng)
    wmi.x_wmi: -0x7ff8f946 - The RPC server is unavailable.

    Is there anyway to acknowledge these errors, but continue on to the next item in the list without the script stopping? Or something I can do to check the status of the computer before passing it along to the WMI function? I am a really big newbie at this sort of thing and apologize for my ignorance.

    Thank you for your time.
    Last edited by anonymous; Jan 15 '08, 08:12 PM. Reason: Updated info about Versions
  • anonymous
    Banned
    New Member
    • Sep 2005
    • 99

    #2
    I managed to get the script to work using the try....finally functions. I managed to stumble upon that in my searches. Hope this helps someone else out there.

    Comment

    Working...