import subprocess
output = subprocess.check_output(('TASKLIST', '/FO', 'CSV')).decode('cp949')
output = output.replace('"', '').split('\r\n')
for elem in output:
if elem.startswith('notepad.exe'):
print('실행됨')
break
else:
print('프로그램 실행안됨')
import win32com.client
wmi = win32com.client.GetObject('winmgmts:')
pids = [p.CommandLine for p in wmi.InstancesOf('win32_process') if p.Name == 'notepad.exe'] # notepad.exe 중 실행 커맨드라인 확인 가능
if pids == []:
print('실행안됨')
else:
print('실행됨')