WebListener icon indicating copy to clipboard operation
WebListener copied to clipboard

Add the ability to run WebListener as a Windows service

Open cofonseca opened this issue 7 years ago • 8 comments

I'd like to figure out how to allow WebListener to run as a Windows service, so that it could be started and left to run in the background without a user needing to be logged in.

Interested in any ideas or feedback that anyone might have on how to accomplish this.

cofonseca avatar Oct 12 '17 13:10 cofonseca

Hi @cofonseca, I have a couple of ideas on how to get your WebListener running as a Windows Service. I will see what I can do when I get home.

CodeBarbarian avatar Oct 13 '17 17:10 CodeBarbarian

I found an article on https://msdn.microsoft.com/en-us/magazine/mt703436.aspx

I will see what I can do with it in the following week.

CodeBarbarian avatar Oct 14 '17 11:10 CodeBarbarian

Excellent @CodeBarbarian , thanks! No rush on this at all - it's a pretty low priority for me.

I came across the same article a few days ago but haven't really had time to dig into it. I'm very interested to see what you come up with. Feel free to reach out if there's anything I can assist with.

cofonseca avatar Oct 14 '17 15:10 cofonseca

I tried using the NSSM at http://nssm.cc/

Start-Process -FilePath .\nssm.exe -ArgumentList 'install YourServiceNameHere "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-command "& { . C:\Scripts\WebListener\Start-WebListener.ps1; Start-WebListener }"" ' -NoNewWindow -Wait

It works.

NSSM is a service helper that could do exactly what you need. If you rather would like to add legacy service support, it would be by using the article mentioned in the comment from msdn.

CodeBarbarian avatar Oct 18 '17 09:10 CodeBarbarian

Awesome. I'll give it a try this weekend and see how it works out.

What do you think would be the better solution long-term in regards to someone using WebListener for a small project? Downloading NSSM and getting it set up doesn't seem to be difficult, but would take a few extra steps for a user who wanted to use WebListener as a service. Legacy service support would take more work up-front, but would make WebListener easier to use going forward.

I'll try to do a bit more research this weekend but maybe we just add some documentation on how to use this with NSSM in the meantime, and shoot for service support in the future. Thoughts?

cofonseca avatar Oct 20 '17 11:10 cofonseca

Optionally we could try using the New-Service Cmdlet in Powershell?

CodeBarbarian avatar Oct 20 '17 18:10 CodeBarbarian

Optionally we could try using the New-Service Cmdlet in Powershell?

You still need to have ServiceManagement functions, for the OS to recognize it as 'service'

NSSM is a great tool, but if you don't want to use it (or can't for any reason), you can have almost 'service'-like experience with Task Scheduler. You will only miss service management functions.

al-ign avatar Nov 24 '17 07:11 al-ign

Another option would be to start the powershell script from task scheduler when the computer starts.

RobWoods-CPG avatar Aug 20 '20 23:08 RobWoods-CPG