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.
Locked
laned101
Posts: 28
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: 14676
Joined: Tue May 22, 2007 9:57 am
Answers: 6
Has voted: 1 time
Been upvoted: 5 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: 28
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: 14676
Joined: Tue May 22, 2007 9:57 am
Answers: 6
Has voted: 1 time
Been upvoted: 5 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: 28
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.

LonnySamson
Posts: 1
Joined: Fri Dec 11, 2020 3:01 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
Joined: Fri Sep 05, 2014 11:19 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: 7564
Joined: Tue May 29, 2007 4:43 pm
Answers: 2
Been upvoted: 5 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.

Locked