import os import time import win32com.client def check_exsit(process_name): WMI = win32com.client.GetObject('winmgmts:') processCodeCov = WMI.ExecQuery('select * from Win32_Process where Name like "%{}%"'.format(process_name)) if len(processCodeCov) > 0: return True else: return False if __name__ == '__main__': while True : time.sleep( 10 ) res = check_exsit('CSConsole.exe') if not res : print(os.system("1_start_cs.bat")) time.sleep( 10 ) res = check_exsit('GSConsole.exe') if not res : print(os.system("2_start.bat")) time.sleep( 10 ) res = check_exsit('RSConsole.exe') if not res : print(os.system("3_start_rs.bat")) time.sleep( 10 )