I have developed windows application to monitor the current running process and it will scan the running task list via subprocess in defined interval and application running smoothly on IDE but after compiling and execute exe, then it will popup C:\WINDOWS\SYSTEM32\TASKLIST.exe terminal each time when scan the task list. I am highly appreciate your expert supports to avoid this glitch enter image description here
import subprocess
from time import sleep
def check_process_running(self):
process_name = b'CUSTOM_APP.exe'
get_tasklist = 'TASKLIST'
tasklist = subprocess.check_output(get_tasklist)
proc_data = [row for row in tasklist.split(b'\n') if row.startswith(process_name)]
def events_tracker(self):
while True:
try:
tasks = self.check_process_running()
# some calculations
except Exception as e:
logger.exception("event capture triggered exception "+str(e))
time.sleep(5)
When you have built python application (without console) on windows there are missing
sys.stdoutandsys.stderrin the process which cause creation of new console (I think it's because of logic insubprocessmodule). To avoid this on windows you can create detached process by passingcreationflags.This should work: