windows-services

C++ SendInput possible in Windows Service?

只愿长相守 提交于 2019-12-11 01:05:09
问题 First off, I'd like to say that I've used StackOverflow for years, and this is the first time I haven't found an existing answer. A testament to what a valuable resource this is. Background: I'm trying to catch MIDI input from a connected device and have it trigger keyboard events to whichever window has focus. I was able to do this successfully using SendInput in a Windows Console application, but would prefer to run this as a service. I was able to hide the console window and have it work,

Transfer data from Windows Service to Console Application repeatedly

半世苍凉 提交于 2019-12-11 00:49:57
问题 Here is my scenario, I have a windows service that runs a task every 20 minutes, the task is: requesting updates from an API hosted by a remote website. The response is a list of JSON objects, When the Service receives the list, it carries out a set of operations then appends more JSON objects, finally the service must push the list to a running console application. My very specific question is : how to transfer this data from the windows service to the console App both directly and

Using Web API for a Windows Service to Receive Commands and Perform Tasks via Polling?

夙愿已清 提交于 2019-12-11 00:46:10
问题 I have a project where I need to create a windows service that, when instructed via a command, will perform various tasks. This server would run on multiple servers and would effectively perform the same kind of tasks when requested. For example, I would like to have a Web API service that listens for requests from the servers. The service running on the server would send a query to Web API every 25 secs or so and pass to it its SERVERNAME. The Web API logic will then look up the SERVERNAME

Detect Removable Media Ejection Request in Windows Service

女生的网名这么多〃 提交于 2019-12-11 00:46:06
问题 I have a Windows service written in C# with the .NET 2.0 framework that uses the FileSystemWatcher to monitor certain directories for changes. Some of these directories may be on removable media, such as a USB drive. When a new drive is plugged into the system, I get notification through a WMI query and can set up a new FileSystemWatcher. All that works well. The difficulty is that I want the user to be able to eject the drive using the Windows "Safely Remove Hardware" app, but Windows

c# windows-services - How do I handle logging exceptions?

点点圈 提交于 2019-12-11 00:27:13
问题 I am creating a Windows service. When an exception occurrs, I handle it appropriately and create a log. I am using the decorator pattern, as there are many different ways people will be looking at these logs. I have an email logger, a file logger, and a windows event logger, all which inherit from LoggingDecorator, which implements ILogger. So, no logger knows about any other logger. My question is: How should I handle logging exceptions? If writing to a file fails, or sending an email fails,

Can the Service Installer class run in a different Assembly?

怎甘沉沦 提交于 2019-12-11 00:16:50
问题 I have a custom Installer class that is used when installing my Windows Service. Stripped down to the necessary details the class looks like this. [RunInstaller(true)] public class MyWindowsServiceInstaller : Installer { public MyWindowsServiceInstaller() { ServiceProcessInstaller processInstaller = new ServiceProcessInstaller(); ServiceInstaller serviceInstaller = new ServiceInstaller(); processInstaller.Account = ServiceAccount.LocalSystem; serviceInstaller.DisplayName = Program

C# Windows Service doesn't seem to like privatePath

蹲街弑〆低调 提交于 2019-12-10 23:59:24
问题 I wrote a C# Windows Service to handle task scheduling for our application. I'm trying to move the "business rules" assemblies into a bin subdirectory of the scheduling application to make it easier for us to do updates (stop service, delete all files in bin folder, replace with new ones, start service). I added <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <probing privatePath="bin;"/> </assemblyBinding> </runtime> to the service's app config and it works fine if the

How does a windows service set off an application at a standard interval?

放肆的年华 提交于 2019-12-10 23:43:40
问题 A consultant setup a windows service to run a application. The application is supposed to run every 15 minutes. The application is not running at all and the service appears to be running fine. I am not familiar with how an application will run at a standard interval when running as a service. The service uses the SRVANY.EXE tool. 回答1: Any 'consultant' that sets up a service to run using SRVANY.EXE should be fired. SRVANY is an unfortunate hack that should have been retired a decade ago; it

What are windows services? How are they differ from other .NET application?

空扰寡人 提交于 2019-12-10 23:10:04
问题 What are windows services? How are they different from other .NET application? Any references or examples are welcome which sight the differences 回答1: Windows service is a Windows concept and generally does not really have anything to do with .NET per se other than that these could be written in .NET languages. The main difference between a service and an ordinary windows app Services always run (usually started when computer boots; depending on design, you can manually stop or start these)

What is the proper way for a Windows service to fail during its startup

我们两清 提交于 2019-12-10 22:44:48
问题 I need my service to check for existence and structure of certain files during its startup and exit/fail/stop if some conditions aren't met. I read this thread: What is the proper way for a Windows service to fail? but it does not help. I set the ServiceBase.ExitCode property non-zero and then call ServiceBase.Stop. But I get 5 event log entries. See below: Starting service. (I log this event via code) Config.xml file not found. (I log this ERROR event via code) Service stopped successfully.