Windows Service not Stopping

Support for all customers who have purchased a SAPIEN PowerShell Studio product license. This forum does not offer a response time guarantee.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
User avatar
lpalacio
Posts: 9
Joined: Tue Jul 29, 2014 11:13 am

Windows Service not Stopping

Post by lpalacio » Mon Dec 04, 2017 5:01 pm

To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build:
PowerShell Studio 2017 v5.4.145 x64
Operating system:
Windows 10 1703 x64

*** Please add details and screenshots as needed below. ***

When compiling code as a Windows Service and installing the service. Going into the Windows Service Manager and stopping the service does not kill the executable. Is this an issue of the compilation engine or an issue that I need to address on my code?

User avatar
Alexander Riedel
Posts: 6361
Joined: Tue May 29, 2007 4:43 pm

Re: Windows Service not Stopping

Post by Alexander Riedel » Mon Dec 04, 2017 5:07 pm

The service is designed to kill the currently running script on a stop request. Now, depending on what your script does internally that may still keep the process locked and preventing it from terminating.
Without knowing what your script does in detail, that is very hard to answer.
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
lpalacio
Posts: 9
Joined: Tue Jul 29, 2014 11:13 am

Re: Windows Service not Stopping

Post by lpalacio » Tue Dec 05, 2017 9:38 am

Do I need to add code to interact with the OnStop method in order for the executable to stop?

https://msdn.microsoft.com/en-us/librar ... .110).aspx

User avatar
Alexander Riedel
Posts: 6361
Joined: Tue May 29, 2007 4:43 pm

Re: Windows Service not Stopping

Post by Alexander Riedel » Tue Dec 05, 2017 10:31 am

Nope. Not necessary in this version. Your script runs in its own thread. The thread gets killed in the stop request. But if you load types/modules etc that create their own thread they may be left hanging and lock the process. Which is why I would need to know what it is you do in your service.
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
lpalacio
Posts: 9
Joined: Tue Jul 29, 2014 11:13 am

Re: Windows Service not Stopping

Post by lpalacio » Tue Dec 05, 2017 7:02 pm

I created an empty executable with only a blank loop thinking that something on my code was causing the issue and even this wouldn't kill the running executable when stopping the service on windows.
  1. while($true){}
I even tried it with the solitaire killer in the blog example below and that didn't stop either.

https://www.sapien.com/blog/2017/07/12/ ... owershell/

User avatar
Alexander Riedel
Posts: 6361
Joined: Tue May 29, 2007 4:43 pm

Re: Windows Service not Stopping

Post by Alexander Riedel » Tue Dec 05, 2017 7:54 pm

That's kinda weird. I will see what I can find out. Does the service show as stopped in the service panel?
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
lpalacio
Posts: 9
Joined: Tue Jul 29, 2014 11:13 am

Re: Windows Service not Stopping

Post by lpalacio » Wed Dec 06, 2017 11:46 pm

Correct, as far as windows is concerned the service is stopped.

User avatar
lpalacio
Posts: 9
Joined: Tue Jul 29, 2014 11:13 am

Re: Windows Service not Stopping

Post by lpalacio » Sun Dec 10, 2017 1:41 pm

Actually I just did some more testing and Windows is complaining that the service is not responding to the stop command. Not sure if that makes a difference.