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.
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.
Comment