Skip to content

Instantly share code, notes, and snippets.

@tommelo
Last active September 14, 2023 10:27
Show Gist options
  • Save tommelo/be8bc7d0a81a2bfbf56e330f19535189 to your computer and use it in GitHub Desktop.
Save tommelo/be8bc7d0a81a2bfbf56e330f19535189 to your computer and use it in GitHub Desktop.
import os
import sys
import ctypes
import _winreg
def is_running_as_admin():
'''
Checks if the script is running with administrative privileges.
Returns True if is running as admin, False otherwise.
'''
try:
return ctypes.windll.shell32.IsUserAnAdmin()
except:
return False
def execute():
if not is_running_as_admin():
print '[!] The script is NOT running with administrative privileges'
else:
print '[+] The script is running with administrative privileges!'
if __name__ == '__main__':
execute()
@fw-real
Copy link

fw-real commented Sep 14, 2023

thanks, helped a ton!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment