文章詳情頁
Python 怎么操作windows系統服務
瀏覽:77日期:2022-06-28 11:48:35
問題描述
def listservices(): import wmi c = wmi.WMI() for service in c.Win32_Service():#print(service.Caption,service.StartMode,service.State)print(service.Caption) #名稱print(service.StartMode) #啟動類型print(service.State) #狀態if __name__==’__main__’: listservices()
怎么更改啟動類型以及狀態呢?
問題解答
回答1:模塊作者的文檔里有例子
http://timgolden.me.uk/python...
import wmic = wmi.WMI()for service in c.Win32_Service(Name='seclogon'): result, = service.StopService() if result == 0: print 'Service', service.Name, 'stopped' else: print 'Some problem' breakelse: print 'Service not found'
標簽:
Windows系統
相關文章:
排行榜
