Home >Backend Development >Python Tutorial >python 判断一个进程是否存在

python 判断一个进程是否存在

WBOY
WBOYOriginal
2016-06-16 08:47:322168browse

源代码如下:

复制代码 代码如下:

#-*- 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')
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn