当前位置: 编程技术>python
python 判断一个进程是否存在
来源: 互联网 发布时间:2014-09-04
本文导语: 源代码如下: 代码如下:#-*- coding:utf-8 -*- def check_exsit(process_name): import win32com.client WMI = win32com.client.GetObject('winmgmts:') processCodeCov = WMI.ExecQuery('select * from Win32_Process where Name="%s"' % process_name) if len(processCodeCov) > 0: print '%s is exists' % ...
源代码如下:
#-*- coding:utf-8 -*-
def check_exsit(process_name):
import win32com.client
WMI = win32com.client.GetObject('winmgmts:')
processCodeCov = WMI.ExecQuery('select * from Win32_Process where Name="%s"' % process_name)
if len(processCodeCov) > 0:
print '%s is exists' % process_name
else:
print '%s is not exists' % process_name
if __name__ == '__main__':
check_exsit('chrome.exe')
代码如下:
#-*- coding:utf-8 -*-
def check_exsit(process_name):
import win32com.client
WMI = win32com.client.GetObject('winmgmts:')
processCodeCov = WMI.ExecQuery('select * from Win32_Process where Name="%s"' % process_name)
if len(processCodeCov) > 0:
print '%s is exists' % process_name
else:
print '%s is not exists' % process_name
if __name__ == '__main__':
check_exsit('chrome.exe')