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.
This topic is 3 years and 3 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
laned101
Posts: 30
Last visit: Thu Sep 23, 2021 1:12 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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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: 30
Last visit: Thu Sep 23, 2021 1:12 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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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: 30
Last visit: Thu Sep 23, 2021 1:12 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.
LonnySamson
Posts: 1
Last visit: Fri Dec 11, 2020 2:15 am

Re: Windows Service

Post by LonnySamson »

A number of programs cannot be removed while they are running and running. Moreover, it sometimes happens that the program itself seems to be closed, but its process is running (for example, due to an incorrect termination of the application). To find out if your uninstalled application is running, go to the task manager and check.
User avatar
JackMayhoffer
Posts: 3
Last visit: Fri Dec 11, 2020 4:14 am

Re: Windows Service

Post by JackMayhoffer »

A simple system restart would help here, right? If app is uninstalled there simply will not be a service to start after the startup.
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Windows Service

Post by Alexander Riedel »

Simply restarting can leave you with tons of Windows log entries about trying to start a service that no longer exists.
I assume you created the MSI with PowerShell Studio as well. Did you use the services tab in Script Packager to adjust the settings for your service?
Since you have an expired subscription I am not sure you have that.
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 3 years and 3 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked