RylofScripts

Py Script for HC Strat TDS

Aug 26th, 2023
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.85 KB | None | 0 0
  1. # Auto rejoin script, execute when in roblox and the strat script is in autoexec. The process name might be different depending on OS, # windows 10 etcetera,
  2.  
  3. import psutil
  4. import time
  5. import webbrowser
  6. import logging
  7.  
  8. logging.basicConfig(level=logging.INFO)
  9.  
  10. def is_process_running(process_name):
  11.     try:
  12.         for process in psutil.process_iter(attrs=['pid', 'name']):
  13.             current_process = process.info['name']
  14.             logging.info(f"Checking process: {current_process}")
  15.             if current_process == process_name:
  16.                 return True, process.info['pid']
  17.     except Exception as e:
  18.         logging.error(f"An error occurred: {e}")
  19.     return False, None
  20.  
  21. def terminate_process(pid):
  22.     try:
  23.         process = psutil.Process(pid)
  24.         process.terminate()
  25.         logging.info(f"Terminated process with PID: {pid}")
  26.     except Exception as e:
  27.         logging.error(f"An error occurred while terminating the process: {e}")
  28.  
  29. def main():
  30.     process_name = "Windows10Universal.exe"  # Replace with the exact name you see in Task Manager
  31.     check_interval = 7  # time in seconds to check if process is running
  32.     termination_timer = 21 * 60  # 20 minutes in seconds
  33.    
  34.     while True:  
  35.         time.sleep(check_interval)
  36.         logging.info("Checking if the process is running...")
  37.        
  38.         is_running, pid = is_process_running(process_name)
  39.        
  40.         if not is_running:
  41.             logging.info(f"Process {process_name} is not running. Opening Roblox...")
  42.             url = "roblox://placeID=3260590327"
  43.             webbrowser.open_new(url)
  44.         else:
  45.             logging.info(f"Process {process_name} is running. Waiting 20 minutes before termination.")
  46.             time.sleep(termination_timer)  # Wait 20 minutes
  47.             terminate_process(pid)
  48.  
  49. if __name__ == "__main__":
  50.     main()
  51.  
  52.  
Advertisement
Add Comment
Please, Sign In to add comment