#๐Ÿ”’ How (in the WORLD!!!) do you close handles via python?

22 messages ยท Page 1 of 1 (latest)

balmy dove
#

using process explorer (microsoft made app) you can look at applications and (if u run procexp as admin) you can see handles and dlls for whatever apps you want. ive been trying really hard (10 HOURS) to make python close a certain handle for me (ROBLOX_singletonEvent) but every single time i run a script that tries it it DOSENT WORK

so a couple of questions

  1. when i run command prompt as admin (and run my script in there), does the .py script itself also have to be run as admin (or given admin perms if thats a thing)?
  2. if not, why cant i close it then?

any tips and tricks... please... my entire day was burnt on solving this one issue...

dense nacelleBOT
#

@balmy dove

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

balmy dove
#
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!")
#

this is my script if anyone needs to see it

#

ill send my other one that i tried (and that didnt work) here too

#

nvmi wont

#

i cant find the right one

balmy dove
#

bump

white temple
white temple
graceful sentinel
white temple
balmy dove
#

if thats what u meant... by that question

wintry stratus
#

content = file.read()

dense nacelleBOT
#

Hey @wintry stratus!

Please edit your message to use a code block

```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
white temple
#

!rule 5

dense nacelleBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

balmy dove
#

i see. could i ask this question on the reddit or some other forum?

dense nacelleBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.