AttributeError:winmgmts:.Win32_Services

时间:2019-04-22 11:34:09

标签: python winapi win32com

我正在尝试使用以下代码编写脚本以远程运行服务;我收到的是

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()

提及服务应启动

1 个答案:

答案 0 :(得分:0)

尝试将File "main.py", line 45, in gameStart gt = tmx_data.getTileImageByGid File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytmx/pytmx.py", line 214, in __getattr__ raise AttributeError AttributeError 更改为c.Win32_Services

还有IndentationErrors。 方法c.Win32_Service应该是startservice()StartService()是它的显示名称,您应该传递它的服务名称,应该是Adobe Flash Player Update Service

有效的代码是:

AdobeFlashPlayerUpdateSvc