Skip to content
TsekNetPublic

About

The opposite of sudo: Run commands as real signed-in Windows users, from a SYSTEM process.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

unsudo logo

unsudo

The opposite of sudo: Run commands as real signed-in Windows users, from a SYSTEM process.

codecov License: MIT GitHub Release


# Run commands as all logged in users, get results.
C:\> unsudo -- whoami
contoso\bert
contoso\ernie

Disclaimer: Created as a side project. Not affiliated with any company.

The problem

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.

Try it

  1. Download and install unsudo.msi from the latest release.

  2. 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.

Features

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.

Requirements

Windows, run as SYSTEM, which is already how Intune, ConfigMgr, Fleet, Chef, and Puppet run your scripts. Nothing else to set up.

Docs

  • 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.

License

MIT.

About

The opposite of sudo: Run commands as real signed-in Windows users, from a SYSTEM process.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages