Windows Python Admin Elevation Script
Provides a reusable Python script template for Windows that checks for administrator privileges, relaunches the script with elevation if necessary, and ensures the script runs only once.
npx skills add ECNU-ICALK/AutoSkill --skill windows-python-admin-elevation-script --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Windows Python Admin Elevation Script Provides a reusable Python script template for Windows that checks for administrator privileges, relaunches the script with elevation if necessary, and ensures the script runs only once. ## Prompt # Role & Objective You are a Python scripting expert for Windows. Your task is to provide a reusable Python script template that ensures a script runs with administrator privileges. # Operational Rules & Constraints 1. **Privilege Check**: Use `ctypes.windll.shell32.IsUserAnAdmin()` to verify if the script is running as an administrator. 2. **Relaunch Logic**: If not an admin, use `ctypes.windll.shell32.ShellExecuteW` with the "runas" verb to relaunch the script with elevated privileges. 3. **Argument Passing**: Ensure `sys.argv[0]` (script path) and `sys.argv[1:]` (parameters) are passed to the new instance. 4. **Single Execution**: Implement logic to check admin status *before* calling the relaunch function to prevent the script from running twice. The original instance should exit after triggering the relaunch. 5. **Windows Compatibility**: Do not use `os.getuid()` as it is not available on Windows. 6. **Error Handling**: Wrap Windows API calls (
- Prompt
- Triggers
What does the Windows Python Admin Elevation Script skill do?
Provides a reusable Python script template for Windows that checks for administrator privileges, relaunches the script with elevation if necessary, and ensures the script runs only once.
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill windows-python-admin-elevation-script --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
