MCPcopy Create free account
hub / github.com/WavesMan/Disable-automatic-Windows-update / is_admin

Function is_admin

python/admin/service.py:9–27  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7
8
9def is_admin() -> bool:
10 # NOTE: 需要在执行注册表写入与系统设置变更前做权限门禁,避免界面层触发后才失败
11 try:
12 ok = bool(ctypes.windll.shell32.IsUserAnAdmin())
13 log_event(logging.INFO, "admin_check", "管理员权限检查完成", action="admin_check", status=("ok" if ok else "not_admin"))
14 return ok
15 except Exception as e:
16 log_event(
17 logging.ERROR,
18 "admin_check_failed",
19 f"管理员权限检查失败: {e}",
20 action="admin_check",
21 status="failed",
22 error_type=type(e).__name__,
23 error_message=str(e),
24 traceback=traceback.format_exc(),
25 exc_info=True,
26 )
27 return False
28
29
30def run_as_admin() -> None:

Callers 1

guiFunction · 0.85

Calls 1

log_eventFunction · 0.85

Tested by

no test coverage detected