0

I'm trying to run my wpf service with nssm service manager. The problem is that using nssm I can install service, but then when I try to start it I get the following response in terminal:

MyService: Unexpected status SERVICE_PAUSED in response to START control.

Then in EventViewer I get the following error:

Service cannot be started. The service process could not connect to the service controller

Although I can start my service using NET commands, or using VisualStudio, but this problem occurs only with nssm...

Framework: .NET Framework 4.6.1

Any suggestions on how to fix this issue?

EDIT 1

I created sample WPF service using https://learn.microsoft.com/en-us/dotnet/framework/windows-services/walkthrough-creating-a-windows-service-application-in-the-component-designer example. And the result is still the same.

EDIT 2

I managed to get NSSM error:

Cannot start service from the command line or a debugger.  A Windows Service must first be installed (using installutil.exe) and then started with the ServerExplorer, Windows Services Administrative tool or the NET START command.

I don't get how nssm works now....

Nikas Žalias
  • 1,594
  • 1
  • 23
  • 51
  • Can your share your service code? Also, which .NET version are you using? – Pavel Anikhouski Jan 30 '20 at 20:47
  • @PavelAnikhouski sorry I can't share code – Nikas Žalias Jan 31 '20 at 09:29
  • @PavelAnikhouski framework is added to question – Nikas Žalias Jan 31 '20 at 09:29
  • So, the problem is that `installutil.exe` can successfully install and run your service, but `nssm` can't run it? can you share mode details maybe, like logs or error codes. It's hard to figure out the problem since you didn't shared your code – Pavel Anikhouski Jan 31 '20 at 10:14
  • Yes I can run with instlalutil.exe and Visual Sudio my service. There are no error codes. EventViewer shows error and warning. Error: MyService: Unexpected status SERVICE_PAUSED in response to START control. Warning: Service MyService ran for less than 1500 milliseconds. Restart will be delayed by 4000 milliseconds. – Nikas Žalias Jan 31 '20 at 10:19
  • @PavelAnikhouski maybe you have a working service example that does nothing, but can be ran with nssm? Then I could look for problem in my code. – Nikas Žalias Jan 31 '20 at 10:20
  • @PavelAnikhouski I edited my question. I made an example service from the link and still the same result. – Nikas Žalias Feb 03 '20 at 06:35

3 Answers3

1

I found an answer!

I was too dumb to realize that nssm is a service manager, and I tried to run with it a windows service...

All I needed to do is to make a simple console application instead of service...

Nikas Žalias
  • 1,594
  • 1
  • 23
  • 51
0

i glanced through this article while trying to setup a Windows service using nssm and got the same issue. The service didn't start. I was trying to run a python script but the service was instantly failing. I added couple of sleep statements in my script and that did the trick.

Below is my batch file to run Python script:

@echo off
set CURDIR=%~dp0
"C:\Python\Python311\python.exe" "C:\apps\config\run.py"
Rahul
  • 1
  • 1
-1

You can try to make NET COMMANDS to a bat file. Then Use NSSM to make the bat file to service.

CHOW
  • 1
  • 1
  • NSSM is created to make life easier, I don't think that making some bat files aka complicated workarounds will help me solve the problem – Nikas Žalias Jan 30 '20 at 07:15