windows-services

How do I configure the name of a Windows service upon installation (or easily at compile time)?

百般思念 提交于 2019-11-28 17:34:51
I've created a Windows service in C#, installed it on a server and it is running fine. Now I want to install the same service again, but running from a different working directory, having a different config file etc. Thus, I would like to have two (or more) instances of the same service running simultaneously. Initially, this isn't possible since the installer will complain that there's already a service with the given name installed. I can overcome this by changing my code, setting the ServiceBase.ServiceName property to a new value, then recompiling and running InstallUtil.exe again. However

Run Java application as a service

ぃ、小莉子 提交于 2019-11-28 17:34:25
I would like to run a Java application as a service. Unfortunately, I am limited in that I can't use something like the Java Service Wrapper (which does appear to be an excellent tool). Is there any way of running an executable JAR, as a service, without relying on external applications? I currently have the service installed, but it fails to start. This is where I am getting stuck and I haven't been able to find anything on Google other than information about the JSW. There's an LGPL clone of the Java Service Wrapper: http://yajsw.sourceforge.net BTW, IANAL, but I suspect that JSW people are

Why can't I install my service (runtime newer than loaded runtime)?

落花浮王杯 提交于 2019-11-28 17:33:21
So I built a service in C# and I am trying to use the following command to install it: C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\installutil.exe MyService.exe >> installLog.txt It fails. When I look at the installLog.txt, I get this: Microsoft (R) .NET Framework Installation utility Version 2.0.50727.3053 Copyright (c) Microsoft Corporation. All rights reserved. Exception occurred while initializing the installation: System.BadImageFormatException: Could not load file or assembly 'file:///C:\MyService.exe' or one of its dependencies. This assembly is built by a runtime newer than the

Calling async methods from a Windows Service

亡梦爱人 提交于 2019-11-28 17:32:54
I have a Windows Service written in C# that periodically fires off background jobs. Typically, at any given time, several dozen heavily I/O bound Tasks (downloading large files, etc) are running in parallel. The service runs on a relatively busy web server (necessary for now), and I think it could benefit greatly in terms of thread conservation to use asynchronous APIs as much as possible. Most of this work is done. All jobs are now fully async (leveraging HttpClient, etc.), as is the main job loop (with heavy doses of Task.Delay). All that's left is to figure out how to correctly and safely

installing windows service with SC.exe or InstallUtil.exe - there is difference but which?

♀尐吖头ヾ 提交于 2019-11-28 17:25:51
SC.exe and InstallUtil both install/uninstall windows services. But they don't seem to work the same way. What is the difference? For instance InstallUtil fails (some file or dependency not found error) while Sc create happily installs the service. Too add to the strangeness; the service doesn't show up if I run net start in the console. But it does show up in the services GUI. Variants of this happen when I try to uninstall. I have written the service myself and earlier versions work. Dotnet3.5. Yes, installing a service isn't particularly complicated. It just takes writing a handful of

Windows Service that runs Periodically

橙三吉。 提交于 2019-11-28 17:04:47
I'm writing a windows service that once started will run every X hours. The process it completes is fairly intensive, so I want to use a background worker. I'm using a Settings file to store both the hours between runs and the last time the service ran. I'm not exactly sure the best way to do this - that is, I want the service to idle using as few resources as possible, and when it runs, it needs to run in the background worker, report what it did, and then go back into idle mode. I've thought about using 2 background workers. The first worker would be a private local variable for the service

Are there any log file about Windows Services Status?

孤人 提交于 2019-11-28 16:57:37
问题 I want to figure out when the services was start up and terminated. Are there any kind log file about it? 回答1: Take a look at the System log in Windows EventViewer ( eventvwr from the command line). You should see entries with source as 'Service Control Manager'. e.g. on my WinXP machine, Event Type: Information Event Source: Service Control Manager Event Category: None Event ID: 7036 Date: 7/1/2009 Time: 12:09:43 PM User: N/A Computer: MyMachine Description: The Background Intelligent

Use of Timer in Windows Service

孤街浪徒 提交于 2019-11-28 16:44:44
I have a windows service where in I want to create a file every 10 seconds. I got many reviews that Timer in Windows service would be the best option. How can I achieve this? Jon Skeet Firstly, pick the right kind of timer. You want either System.Timers.Timer or System.Threading.Timer - don't use one associated with a UI framework (e.g. System.Windows.Forms.Timer or DispatcherTimer ). Timers are generally simple set the tick interval Add a handler to the Elapsed event (or pass it a callback on construction), Start the timer if necessary (different classes work differently) and all will be well

Simplest way to restart service on a remote computer

你。 提交于 2019-11-28 16:36:46
问题 What's the easiest programmatic way to restart a service on a remote Windows system? Language or method doesn't matter as long as it doesn't require human interaction. 回答1: As of Windows XP, you can use sc.exe to interact with local and remote services. Schedule a task to run a batch file similar to this: sc \\server stop service sc \\server start service Make sure the task runs under a user account privileged on the target server. psservice.exe from the Sysinternals PSTools would also be

Multithreaded service, BackgroundWorker vs ThreadPool?

喜夏-厌秋 提交于 2019-11-28 16:31:24
问题 I have a .NET 3.5 Windows Service. I'm testing with a small application that just sleeps threads after starting them, for random timespans of 300 to 6500ms. I have various questions about this issue. Is BackgroundWorker really intended for use just in WinForms applications or is this just nonsense, how exactly is it tuned to this effect? I've read about ThreadPool s in this question and this one. I'm not exactly sure how much it is a problem for me that the threads would last somewhere