Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Verify if a service is marked for deletion

Tags:

c#

wix

wix3.5

Sometimes when I uninstall the setup (made with WIX) the service remain marked for deletion, and the user must restart the machine to install again. How could I verify that the service is marked for deletion and tell to the user to restart the computer before making other installation?

like image 572
ctescu Avatar asked Oct 30 '25 19:10

ctescu


1 Answers

Generally speaking, this scenario occurs when something remains latched onto that service, preventing Windows from removing its configuration in the registry. (In most cases, it's simply the Services applet -- services.msc -- left open by accident in the background.)

For detection, I suggest you read up on CreateService and other Service API. For example, you'll receive ERROR_SERVICE_MARKED_FOR_DELETE upon calling CreateService if the service is marked for deletion.

Regarding your proposed reboot solution... Windows has advanced far enough to not require a reboot for nearly any reason. Unless you're installing specialized kernel drivers, you do not need to reboot. Don't be lazy! Keep the user in mind! I recommend altering your installer logic to detect potentially conflicting running programs, like the Services applet, and suggest closure.

like image 123
Rafael Rivera Avatar answered Nov 02 '25 09:11

Rafael Rivera