Skip to content

Commit

Permalink
Check first if daemon service is installed during cleanup
Browse files Browse the repository at this point in the history
With having a check if the service is installed before trying to
stop and delete it will reduce unnecessary UAC prompts, as  stop
and delete are privilege operations but checking if a service is
installed doesn't need elevated privileges
  • Loading branch information
anjannath committed Jun 22, 2020
1 parent 8e7cc28 commit e3e4703
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pkg/crc/preflight/preflight_checks_tray_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,17 @@ func fixDaemonServiceInstalled() error {
}

func removeDaemonService() error {
err := service.Stop(constants.DaemonServiceName)
if err != nil {
return fmt.Errorf("Failed to stop the daemon service: %v", err)
// try to remove service if only it is installed
// this should remove unnecessary UAC prompts during cleanup
// service.IsInstalled doesn't need an admin shell to run
if service.IsInstalled(constants.DaemonServiceName) {
err := service.Stop(constants.DaemonServiceName)
if err != nil {
return fmt.Errorf("Failed to stop the daemon service: %v", err)
}
return service.Delete(constants.DaemonServiceName)
}
return service.Delete(constants.DaemonServiceName)
return nil
}

func checkIfDaemonServiceRunning() error {
Expand Down

0 comments on commit e3e4703

Please sign in to comment.