Documentation
¶
Overview ¶
Package runas launches a process as a different user, given a credential.
This is the modern, in-process replacement for the legacy run-as trick:
cmd /c echo <password> | su.exe svc-install "cmd" -l
Every variant of that — su.exe, a keyed userexec.exe, runas piped a password — is doing one Win32 thing: CreateProcessWithLogonW. This package calls it directly, so there is no helper EXE, no echo pipe, and the password never lands on a command line or in the process list.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrUnsupportedPlatform = errors.New("winadmin/runas: only supported on Windows")
ErrUnsupportedPlatform is returned when run-as is invoked off Windows.
Functions ¶
Types ¶
type Options ¶
type Options struct {
// CommandLine is the full command line to execute, e.g.
// `C:\Windows\System32\cmd.exe /c icacls C:\foo /grant grp:M`.
CommandLine string
// WorkingDir is the starting directory ("" -> inherit).
WorkingDir string
// Wait blocks until the launched process exits.
// When false, returns as soon as the process is created (@NOWAIT).
Wait bool
// LoadProfile loads the target user's profile (runas /profile). Needed when
// the command reads HKCU or the user's environment.
LoadProfile bool
}
Options controls how the command is launched.
Click to show internal directories.
Click to hide internal directories.