Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve and unify disabling of Windows services
Refactor, unify and improve the logic to to start/stop and enable/disable services, and also add more documentation. Rework functions: - Unify way of disabling Windows services using templating. - Capitalize as `startupMode` (where startup is single word) everywhere. - Use also text parameters (automatic, manual..) instead of numeric values (2,3...) when providing parameters to any service disable function. Improve documentation: - Add reference URLs about disabled services. - Add more code documentation for querying status and allowed values. Logic improvements include: - Check if service is running before stopping/starting the service. - Do not start the service it's not an Automatic service. - Check whether service is already disabled. - When reverting, start the service if it has Automatic startup. But do not start the service it has different startup (e.g. manual). Also starts the service even though start up is configured as desired (before it quit before doing service start). Improve outputs (logs): - Remove false-positive error messages. - When a service cannot be stopped/start; mention in output that the service will be started/stopped after reboot. - Show success message once service is enabled/disabled. - Fix reboot messages when enabling/disabling services, - Do not write stderr if service cannot be stopped/started as it's not not the main goal of the function. Add missing revert code for the ones missing them: - Disable diagnostics telemetry - Disable Windows Media Player Network Sharing Service > Function: DisableServiceInRegistry - Fix not exitting if service does not exist when reverting - Show success message once service is enabled/disabled - Fix double "Enabled.." messages - Fix unintended registry addition > Function: DisablePerUserService - Change implementation to call DisableServiceInRegistry. - Fix both services are skipped if one of them fails. - Fix reverting a service sets wrong startup mode.
- Loading branch information