Relaunch through UAC when (un)installing the service unprivileged
--install-service/--remove-service on Windows no longer fail with 'Access is denied' from a normal shell: the process re-runs itself via ShellExecuteEx 'runas', waits for the elevated child and mirrors its exit code. The child gets --elevated-child and pauses for a keypress so its console output stays readable. Declining the prompt reports 'UAC prompt declined'.
This commit is contained in:
@@ -31,5 +31,12 @@ func Run(run func(ctx context.Context) error) error {
|
||||
// Install is unsupported on non-Windows, non-Linux platforms.
|
||||
func Install(string, bool) error { return errUnsupported }
|
||||
|
||||
// Remove is unsupported on non-Windows platforms.
|
||||
// Remove is unsupported on non-Windows, non-Linux platforms.
|
||||
func Remove() error { return errUnsupported }
|
||||
|
||||
// Elevated is always true here: there is no UAC concept, and privilege
|
||||
// errors surface from the failing operation with a "run as root" hint.
|
||||
func Elevated() bool { return true }
|
||||
|
||||
// RelaunchElevated is unsupported on non-Windows, non-Linux platforms.
|
||||
func RelaunchElevated([]string) (int, error) { return 0, errUnsupported }
|
||||
|
||||
Reference in New Issue
Block a user