我正在尝试编写一个脚本来远程运行服务,使用以下代码;为此我收到:
Error:: AttributeError: winmgmts.Win32_Services
我试着查看这个博客WMI lib to start windows service remotely,但没有得到太多帮助。你知道吗
def start_services():
c = wmi.WMI()
for services in c.Win32_Services(Name="Adobe Flash Player Update Service"):
result = services.startservice()
if result == 0:
print("Service :",services.name)
else:
print("Service Already is Start State")
start_services()
服务应该启动
尝试将
c.Win32_Services
更改为c.Win32_Service
。你知道吗还有缩进错误。 方法
startservice()
应该是StartService()
。Adobe Flash Player Update Service
是它的显示名,您应该传递它的服务名,应该是AdobeFlashPlayerUpdateSvc
。你知道吗有效的代码是:
相关问题 更多 >
编程相关推荐