Windows Service

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Post Reply
laned101
Posts: 25
Joined: Thu Aug 16, 2018 3:36 am
Answers: 1

Windows Service

Post by laned101 »

I have created a windows service app with powershell and studio. I have included a few WinForm GUIs to help with configuration etc. I have noticed that now when uninstalling the application it doesn't remove the service from the services list. I can't work out why any help would be appreciated.

jvierra
Posts: 14611
Joined: Tue May 22, 2007 9:57 am
Answers: 2
Has voted: 1 time
Been upvoted: 3 times
Contact:

Re: Windows Service

Post by jvierra »

The most common reason for this is that service has not been shut down properly which prevents it from uninstalling.

laned101
Posts: 25
Joined: Thu Aug 16, 2018 3:36 am
Answers: 1

Re: Windows Service

Post by laned101 »

Yes I noticed it's only when the service is active. I thought it would shutdown as part of the uninstall process? Is this not the case? hmm might be able to add that as a custom action during uninstall.

jvierra
Posts: 14611
Joined: Tue May 22, 2007 9:57 am
Answers: 2
Has voted: 1 time
Been upvoted: 3 times
Contact:

Re: Windows Service

Post by jvierra »

If a service cannot be shut down then it cannot be uninstalled.

You cannot run a GUI from a service.

If a service throws an exception it can become hung and cannot be uninstalled. Stop the service and set it to manual. Restart the system and then un install the service.

laned101
Posts: 25
Joined: Thu Aug 16, 2018 3:36 am
Answers: 1

Re: Windows Service

Post by laned101 »

My Service code runs separate from my GUI code, the GUI code is packaged as part of the MSI.

When I uninstall the Application from Add Remove Programs, you'd think it would stop the service then remove it. But not to worry I'll write the logic to do it.

Post Reply