# Run commands as all logged in users, get results.
C:\> unsudo -- whoami
contoso\bert
contoso\ernieDisclaimer: Created as a side project. Not affiliated with any company.
Your deployment tool (Intune, ConfigMgr, Fleet, a scheduled task, ...) runs as SYSTEM.
But per-user installs, winget in user scope, and writes to HKCU have to run as the
person signed in, which SYSTEM can't do, so they fail or land in the wrong profile. unsudo
runs your command as the signed-in user(s) and hands back the output and the real exit code.
-
Download and install
unsudo.msifrom the latest release. -
Launch your script as SYSTEM (Puppet, Chef, Fleet, Intune, Scheduled Task, etc.), example:
unsudo -- "C:\path\to\setup.exe" /silent
If nobody is signed in, unsudo schedules it for real users the next time they sign-in.
| Feature | Description |
|---|---|
| Runs as the signed-in user | Launches your program in a logged-on user's session, with their token, profile, and environment, from a SYSTEM process. |
| Output and real exit code | Captures the program's output and passes its exit code straight back, so your deployment knows whether it worked. |
| Every user, or one | Hits every signed-in user by default; narrow to the active session, a named -user, or a -session id. |
| Logon deferral | Nobody signed in? Schedules the command to run once at the next sign-in instead of failing. -nodefer opts out. |
| winget and shell commands | -shell "..." runs a cmd.exe line for Store aliases like winget that don't resolve as a plain program. |
| Event Log | Records every run, schedule, and deferred execution to the Windows Event Log, the only way to see what deferred runs did. |
| Only descends privilege | Hands the child the user's lower-privileged token; needs SeTcbPrivilege (SYSTEM) and never elevates. |
| One binary, no service | A single Go executable you can sign and allowlist. No service, no agent, no C# compiled at runtime. |
| Hardened deferred jobs | Refuses a scheduled job whose spec files are writable by non-admins, the SSH StrictModes rule. |
| JSON output | -json emits per-session results (user, exit code, output) for management pipelines. |
Windows, run as SYSTEM, which is already how Intune, ConfigMgr, Fleet, Chef, and Puppet run your scripts. Nothing else to set up.
- Usage , commands, flags, targeting multiple users, exit codes, Event Log logging, and the "nobody logged in" deferral and its one gotcha.
- Design , how it works (the Win32 session-token mechanism).
- Architecture , the design decisions (logon deferral, the job spec, what's verified).
- Security , threat model and hardening (code-sign & allowlist before wide deployment).
One static Go binary, no dependencies, no service. Contributions welcome, see CONTRIBUTING.md.
MIT.
