make a windows service from executable - windows

I'm looking for a way to create a Windows service from an executable that is not a service itself. Do I need a wrapper service to response Windows service calls that calls non-service process?
Note: I'm familiar with SC.EXE and how to make a service. unfortunately when starting services made from non-service executable, I'm getting 1053 timout error.

Try to look on how to use srvany.exe, it should be a tool allowing to launch an app as a service.

Related

error 1053 when starting a service installed by install4j

I am trying to make a bundled JBoss AS 7 into my exe, and install it as a service, so in the "Install a Service" action, I use [Other Service Executable], and give it the full path to standalone.bat so that it could execute it.
The service gets installed correctly, however when I try to start it , it gives me the error 1053
Error 1053: The service did not respond to the start or control
request in a timely fashion
What it is that I could have missed?
"standalone.bat" is not a service executable, so it cannot be started by the service manager. Either you have a 3rd party service executable for JBoss, or you can set up a generated service launcher in install4j that mimics the call made in standalone.bat.

How to call an already running windows service?

Is there anyway to call a windows service that's already running or a process to get info? What my goal is to find out if my windows service is an infinite loop or dead lock and see if it responds. So I want to be able to pass an argument from another program to a windows service and want it to to return a string or number. Is this possible? I can change the windows service to accommodate this. I am thinking of an event or something.
Note: I am not supposed to have the service write to a file or database.
You can host a WCF service in your Windows Service which you could call to get status information.
Here are a couple of links on doing that:
Can I host a WCF Service in a windows service?
How to: Host a WCF Service in a Managed Windows Service

Determine how a Windows service was started

I have a Windows service that with Start Type = Automatic, so that the service starts on boot. If the user stops my service explicitly and restarts it (or some other component of my product stops my service explicitly and restarts it), I need to know that and behave differently in the service.
Is there an API to detect "this service was started automatically by Windows on boot" vs "this service was started manually"? I can't find one on MSDN.
Thanks in advance!

wcf windows service interaction

I have a windows service in which i host a wcf service.
What is the best approach to control the windows service via the wcf service? I already created the interfaces for the wcf service, but I have no idea how to interact with the windows service's classes and functions.
just to check that I'm understanding your problem correctly - you want to run a wcf service, so you create a windows service to host it, and you want your desktop client to be able to control the windows service (that's hosting the wcf service) by talking to the wcf service?
If that's the case, what is it that you're trying to do with the windows service? In some of the work I've done, I've set up the server such that there's the windows service hosting all the wcf services I want to run, and in order to interact with that windows service remotely (e.g. starting/stopping/restarting) I have another service running on the server (usually baked into the Amazon instance image so it's running on every new server that gets brought up) which my remote client can talk to instead. That way I have a means to trigger a service restart on all my servers without having to manually connect/remote desktop to each server. Of course, the second wcf service is secured by some means so it can't be exploited easily.
Is that the sort of thing you're looking to do?

Writing Windows service in WCF

I want to write windows service in wcf After searching a lot I only found were tutorials of writing webservice in wcf not windows service.
Can any one please provide a link to any tutorial which explains how to write windows service in WCF
Windows services are executables. WCF applications are, generally, web services, exposed over a URI. You can host a WCF application within a windows service, not the other way around.
To create a Windows service in C#, follow the step-by-step here. To make your Windows service WCF-enabled, if you will, create the System.ServiceModel.ServiceHost instance that will host your WCF service inside the OnStart() callback.
Good answers all of them. Just a quick note... implement your WCF service in a class library (dll) so you can then host it anywhere you like (IIS, Console App, or Windows Service).
I'd recommend starting from a console application, after your service works as expected, create a Windows Service, add a reference to you library and start the service (WCF) from there (Windows Service)
Edit: I just assumed you meant create a WCF service hosted as a Windows Service, if that's not the case please ignore my answer.
Create your WCF service as normal, create a Windows Service and then use ServiceHost to self-host the WCF service in your Windows Service. See this MSDN page for more information about self-hosting WCF services.

Resources