So i have a script with the code
import os
import subprocess
import psutil
def checkIfProcessRunning(processName):
'''
Check if there is any running process that contains the given name processName.
'''
#Iterate over the all the running process
for proc in psutil.process_iter():
try:
# Check if process name contains the given name string.
if processName.lower() in proc.name().lower():
return True
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
pass
return False;
Then after executes
while True:
if checkIfProcessRunning('TDR'):
print('TDR (tdr.exe) is running')
else:
print('TDR (tdr.exe) is not running')
subprocess.call("cmd /c data.vbs") # Executes other code
This whole script detects if the process tdr.exe is open or not, when the code detects that it isn't open i want it to open some other code but i want it to only do it once instead of looping.