

from __future__ import print_function import ctypes, sys, os def is_admin(): try: return ctypes.windll.shell32.IsUserAnAdmin() except: return False if is_admin(): os.startfile("system-jg_new.exe") else: if sys.version_info[0] == 3: ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1) os.startfile("system-jg_new.exe") else: # in python2.x ctypes.windll.shell32.ShellExecuteW(None, u"runas", unicode(sys.executable), unicode(__file__), None, 1)
Python权限提升脚本解析
本文介绍了一个Python脚本,该脚本用于检查当前运行环境是否具有管理员权限,并在没有权限时尝试提升权限以运行特定的exe文件。通过使用ctypes模块与Windows API交互,实现跨Python版本的权限提升功能。
450

被折叠的 条评论
为什么被折叠?



