0
点赞
收藏
分享

微信扫一扫

python检测进程是否存在

九点韶留学 2022-05-18 阅读 134
# 使用win32com来判断进程是否存在
import win32com.client
def proc_exist(process_name):
is_exist = False
wmi = win32com.client.GetObject('winmgmts:')
processCodeCov = wmi.ExecQuery('select * from Win32_Process where name=\"%s\"' %(process_name))
if len(processCodeCov) > 0:
is_exist = True
return is_exist

if proc_exist('chrome.exe'):
print('chrome.exe is running')
else:
print('no such process...')





举报

相关推荐

0 条评论