How do i delete handles via python? /u/FabulousInterview453 Python Education

Bassicaly ive been trying to delete this handle related to RobloxPlayerBeta.exe
handle is ROBLOX_singletonEvent
Ive been running command prompt as admin and this still wont work
ive been trying… for ten hours… im about to just make python do it manually.

here is my script

“`
import time
import win32file
import win32con

def close_singleton_event_handle():
try:
handle_roblox = r’\Sessions\1\BaseNamedObjects\ROBLOX_singletonEvent

# below is to give time for roblos to acctualy load the handle (might not be nessecary)(idk how long it tkaes to load)

print(“Waiting for singleton handle to be created…”)
time.sleep(5)

handle = win32file.CreateFile(
handle_roblox,
win32con.GENERIC_READ | win32con.GENERIC_WRITE,
0, # No sharing
None, # No security attributes
win32con.OPEN_EXISTING,
0, # No flags
None
)

print(f”Handle {handle_roblox} opened successfully!”)

win32file.CloseHandle(handle)
print(f”Closed handle {handle_roblox} successfully!”)
return True

except Exception as e:
print(f”Error while trying to close handle: {e}”)
return False

it_works = close_singleton_event_handle()

if it_works:
print(“Singleton handle closed. Proceeding with next steps…”)
# Example subprocess to run the next script
import subprocess
subprocess.run([“python”, “fcBrowser2.py”])
else:
print(“Oops!”)
“`

submitted by /u/FabulousInterview453
[link] [comments]

​r/learnpython Bassicaly ive been trying to delete this handle related to RobloxPlayerBeta.exe handle is ROBLOX_singletonEvent Ive been running command prompt as admin and this still wont work ive been trying… for ten hours… im about to just make python do it manually. here is my script “` import time import win32file import win32con def close_singleton_event_handle(): try: handle_roblox = r’\Sessions\1\BaseNamedObjects\ROBLOX_singletonEvent # below is to give time for roblos to acctualy load the handle (might not be nessecary)(idk how long it tkaes to load) print(“Waiting for singleton handle to be created…”) time.sleep(5) handle = win32file.CreateFile( handle_roblox, win32con.GENERIC_READ | win32con.GENERIC_WRITE, 0, # No sharing None, # No security attributes win32con.OPEN_EXISTING, 0, # No flags None ) print(f”Handle {handle_roblox} opened successfully!”) win32file.CloseHandle(handle) print(f”Closed handle {handle_roblox} successfully!”) return True except Exception as e: print(f”Error while trying to close handle: {e}”) return False it_works = close_singleton_event_handle() if it_works: print(“Singleton handle closed. Proceeding with next steps…”) # Example subprocess to run the next script import subprocess subprocess.run([“python”, “fcBrowser2.py”]) else: print(“Oops!”) “` submitted by /u/FabulousInterview453 [link] [comments] 

Bassicaly ive been trying to delete this handle related to RobloxPlayerBeta.exe
handle is ROBLOX_singletonEvent
Ive been running command prompt as admin and this still wont work
ive been trying… for ten hours… im about to just make python do it manually.

here is my script

“`
import time
import win32file
import win32con

def close_singleton_event_handle():
try:
handle_roblox = r’\Sessions\1\BaseNamedObjects\ROBLOX_singletonEvent

# below is to give time for roblos to acctualy load the handle (might not be nessecary)(idk how long it tkaes to load)

print(“Waiting for singleton handle to be created…”)
time.sleep(5)

handle = win32file.CreateFile(
handle_roblox,
win32con.GENERIC_READ | win32con.GENERIC_WRITE,
0, # No sharing
None, # No security attributes
win32con.OPEN_EXISTING,
0, # No flags
None
)

print(f”Handle {handle_roblox} opened successfully!”)

win32file.CloseHandle(handle)
print(f”Closed handle {handle_roblox} successfully!”)
return True

except Exception as e:
print(f”Error while trying to close handle: {e}”)
return False

it_works = close_singleton_event_handle()

if it_works:
print(“Singleton handle closed. Proceeding with next steps…”)
# Example subprocess to run the next script
import subprocess
subprocess.run([“python”, “fcBrowser2.py”])
else:
print(“Oops!”)
“`

submitted by /u/FabulousInterview453
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *