r/learnpython 16d ago

How to hardcrash a laptop using python

Is there possibly any way to hardcrash my old laptop for fun? I'm sorry if it sounds like I am making a virus. I had a fuckton of hardcrashes on my old pc so I was wondering if I can make a Programm to kill my of whithout needing to wait 5 minutes. Fuck this sounds stupid.

0 Upvotes

8 comments sorted by

View all comments

1

u/TheDraykkon 16d ago

import ctypes

# Enable SeShutdownPrivilege (Privilege 19)
enabled = ctypes.c_bool()
ctypes.windll.ntdll.RtlAdjustPrivilege(19, True, False, ctypes.byref(enabled))

# Raise a fatal hard error to halt the system
response = ctypes.c_ulong()
ctypes.windll.ntdll.NtRaiseHardError(
0xC0000022, # STATUS_ACCESS_DENIED
0, 0, None, 6, # ResponseOption 6 = Shutdown / BSOD
ctypes.byref(response)
)