Questions tagged [windows-services]

Windows services are background service processes run by the Service Control Manager on Windows NT based operating systems, similar to daemons or UNIX services.

Windows services, also referred to as NT services, are background service processes run by the Service Control Manager based on the service settings and optionally restarted as needed. Windows services are also capable of being launched on demand, based on other service dependencies.

See also Introduction to Windows Service Applications

8974 questions
126
votes
13 answers

Automatically start a Windows Service on install

I have a Windows Service which I install using the InstallUtil.exe. Even though I have set the Startup Method to Automatic, the service does not start when installed, I have to manually open the services and click start. Is there a way to start it…
mickyjtwin
  • 4,960
  • 13
  • 58
  • 77
125
votes
11 answers

windows service vs scheduled task

What are the cons and pros of windows services vs scheduled tasks for running a program repeatedly (e.g. every two minutes)?
Manu
  • 28,753
  • 28
  • 75
  • 83
122
votes
32 answers

Error 5 : Access Denied when starting windows service

I'm getting this error when I try to start a windows service I've created in C#: My Code so far: private ServiceHost host = null; public RightAccessHost() { InitializeComponent(); } protected override void OnStart(string[] args) { host =…
TheBoubou
  • 19,487
  • 54
  • 148
  • 236
121
votes
19 answers

System.BadImageFormatException: Could not load file or assembly (from installutil.exe)

I am trying to install a Windows service using InstallUtil.exe and am getting the error message System.BadImageFormatException: Could not load file or assembly '{xxx.exe}' or one of its dependencies. An attempt was made to load a program with an…
Epaga
  • 38,231
  • 58
  • 157
  • 245
115
votes
11 answers

(SC) DeleteService FAILED 1072

Last time I create WAS profile and WASService then I try to config and run many script for learn how to config WAS, Finally it crash so i use wasprofile delete this profile and forgot delete WASService. Now I found IBM Webphere Application Server…
Fuangwith S.
  • 5,654
  • 8
  • 37
  • 41
115
votes
11 answers

Windows service on Local Computer started and then stopped error

Usually, I get this error: (The "service name" service on Local Computer started and then stopped. Some services stop automatically if they are not in use by other service or programs) when there's something wrong with my code, like non-existing…
Blackator
  • 1,531
  • 4
  • 17
  • 22
114
votes
14 answers

How to check if a service is running via batch file and start it, if it is not running?

I want to write a batch file that performs the following operations: Check if a service is running If is it running, quit the batch If it is not running, start the service The code samples I googled so far turned out not to be working,…
citronas
  • 19,035
  • 27
  • 96
  • 164
108
votes
6 answers

Best Timer for using in a Windows service

I need to create some windows service which will execute every N period of time. The question is: Which timer control should I use: System.Timers.Timer or System.Threading.Timer one? Does it influence on something? I am asking because I heard many…
nKognito
108
votes
5 answers

Inno Setup for Windows service?

I have a .Net Windows service. I want to create an installer to install that windows service. Basically, it has to do the following: Pack installutil.exe (Is it required?) Run installutil.exe MyService.exe Start MyService Also, I want to provide…
softwarematter
  • 28,015
  • 64
  • 169
  • 263
104
votes
10 answers

Installing multiple instances of the same windows service on a server

So we've produced a windows service to feed data to our client application and everything is going great. The client has come up with a fun configuration request that requires two instances of this service running on the same server and configured…
Switters
  • 1,553
  • 2
  • 12
  • 13
103
votes
11 answers

How do I create an InstallShield LE project to install a windows service?

I downloaded Visual Studio 2012 yesterday when it was released on MSDN. I have noticed that a few of the project types that we had in 2010 are gone or different. The biggest difference for me right now is the removal of the Windows Installer…
fizch
  • 2,599
  • 3
  • 30
  • 45
100
votes
5 answers

What directory does a Windows Service run in?

I've created a very simple .NET Windows Service and installed it using InstallUtil.exe utility. In the service I have a piece of code as such: if (File.Exists("test_file.txt")) { // Do something clever } I've created a file called test_file.txt…
Guy
  • 65,082
  • 97
  • 254
  • 325
94
votes
9 answers

Stopping a windows service when the stop option is grayed out

I have created a windows service and in the service in control panel -> administrative tools -> services, its status is starting. I want to stop this service, but the stop option is grayed out. How can I start/stop the service? Every time I restart,…
DotnetSparrow
  • 27,428
  • 62
  • 183
  • 316
92
votes
4 answers

Install Windows Service with Recovery action to Restart

I'm installing a Windows Service using the ServiceProcessInstaller and ServiceInstaller classes. I've used the ServiceProcessInstaller to set the start type, name, etc. But how do I set the recovery action to Restart? I know I can do it manually…
Ray
  • 45,695
  • 27
  • 126
  • 169
91
votes
6 answers

Windows service start failure: Cannot start service from the command line or debugger

hi i'm getting this error Cannot start service from the command line or debugger. A winwows Service must first be installed(using installutil.exe) and then started with the ServerExplorer, Windows Services Afministrative tool or the NET START…
paxcow
  • 1,670
  • 3
  • 17
  • 32