0

I have a function that checks the list of task manager processes and, if it's not present there, starts and .exe that, in its turn, executes processes from the list:

while True:
    process_names = (process_names.name() for process_names in psutil.process_iter()) # <- task mngr processes
    if "UiPath.Executor.exe" not in process_names: # checks if executor is running a bot
        try:
            if list_index < len(list_of_botPathSel):  # this if block makes sure we don't go out of bounds of the list
                PROCESS_PATH = list_of_botPathSel[list_index]
                process_name = list_of_botNameSel[list_index]
                os.popen(f'{EXECUTOR_PATH} -file {PROCESS_PATH}') # the cmd command 

                print("The process started: " + process_name)
                list_index = list_index + 1
            else:
                print("Execution of all the robots on the list ended successfully.")
                break
        except:
            print("Exception occurred.")
            break
    else:
        print("The robot is running...")
        time.sleep(15) # seconds
        continue # continue should retry the while loop
    time.sleep(5)

I'm trying to make a button that would stop the .exe.

def killProcess():
   os.popen(f'taskkill /IM "UiPath.Executor.exe" /F')
      
    
#creates a stop button for the current iteration
stopButton = Button(root, text=" Stop the Robot ", command=killProcess, justify=LEFT, anchor = "w")
stopButton.grid(sticky = W, row=list_length+2, column=0, padx=10, pady=(10,15))

When I make the button outside the loop it doesn't work. If I put it inside the loop it is still unclickable. Any help would be appreciated.

miatochai
  • 343
  • 3
  • 15

0 Answers0