Suppress stacktrace with runas with no password

This commit is contained in:
twangboy 2024-10-16 15:01:33 -06:00 committed by Daniel Wozniak
parent 905f8c9826
commit 61890f79af

View file

@ -185,7 +185,12 @@ class HANDLE(wintypes.HANDLE):
def Close(self, CloseHandle=kernel32.CloseHandle):
if self and not getattr(self, "closed", False):
try:
CloseHandle(self.Detach())
except Exception:
# Suppress the error when there is no handle (WinError 6)
if ctypes.get_last_error() == 6:
pass
__del__ = Close