import time def check_exsit(process_name): import win32com.client WMI = win32com.client.GetObject('winmgmts:') processCodeCov = WMI.ExecQuery('select * from Win32_Process where Name="%s"' % process_name) if len(processCodeCov) > 0: return False else: return True if(check_exsit('mayabatch.exe') == False): while(True): if(check_exsit('mayabatch.exe')): ###print 'shutdown!' os.system('shutdown -s -f -t 10') break else: print 'mayabatch.exe...wating' time.sleep(3) else: print ("mayabatch.exe...no found...exit")