windows-services

TService won’t process messages

核能气质少年 提交于 2019-11-30 10:36:32
I have created a windows service that uses Windows Messaging System. When I test the app from the debugger the Messages go through nicely but when I install it my messag … asked 14 mins ago vladimir 1tuga Services don't generally receive window messages. They don't necessarily have window handles at all. Even if they do, they run in a separate desktop. Programs cannot send messages from one desktop to another, so a service can only receive messages from another service, or from a program started by a service. Before Windows Vista, you could have configured your service to interact with the

UWP App Communication with Windows Service

夙愿已清 提交于 2019-11-30 10:03:46
We are fixing to re-architect an application and are debating whether or not it is possible to use UWP instead of an ordinary WPF application. Our application needs the ability the access the entire filesystem and all system resources. This is an issue since UWP apps are sandboxed. However, we are trying to bypass that issue by trying to approach it in this manner: Windows Service -> Running on the system at all times. This will host the core functionality when it comes to accessing and modifying system resources. UWP Application -> Since UWP is sandboxed, the UWP app will forward all system

How can I delete a service in Windows?

一世执手 提交于 2019-11-30 10:03:00
问题 I have a couple old services that I want to completely uninstall. How can I do this? 回答1: Use the SC command, like this (you need to be on a command prompt to execute the commands in this post): SC STOP shortservicename SC DELETE shortservicename Note: You need to run the command prompt as an administrator, not just logged in as the administrator, but also with administrative rights. If you get errors above about not having the necessary access rights to stop and/or delete the service, run

Windows Service or Task Scheduler for maintenance tasks?

依然范特西╮ 提交于 2019-11-30 09:49:20
I have a C# Application that does some maintenance tasks. It needs to run roughly every hour, although it's not too important if it's a bit off. And it has to run on a Win2003 Server with no one logged in. Basically I wonder if I should write a Windows Service, and if yes, if Thread.Sleep() is a proper way to pause the Thread for an hour, or if there are better ways to make sure the Thread stays idle and does not put any server load? (aka. what is the most opposite of a Spinlock) The alternative is the Windows Task Scheduler, but I am not sure if that is good for server use since a) i'd have

Enable windows service programmatically

半腔热情 提交于 2019-11-30 09:25:03
问题 I am trying to enable a windows service programmatically by modifying the value in registry as below. The value does change. However, I am not able to start the service after that because windows still seeing it as disabled. public void EnabledTheService(string serviceName) { try { RegistryKey key = Registry.LocalMachine .OpenSubKey(@"SYSTEM\CurrentControlSet\Services\" + serviceName, true); key.SetValue("Start", 2); } catch (Exception ex) { Console.Write(ex.Message); } } public void

Getting user Idle time in C#?

不羁的心 提交于 2019-11-30 08:54:45
I found this tutorial on how getting Idle time of the user Idle Time . The problem is that it will only work if the application runs on the user. And my application runs on SYSTEM. How can I get the idle time? or if PC is idle? As I understood, you are okay with the result of GetLastInputInfo function. Thus I would suggest the following. Now, suppose you have executable A that runs under Local System account. Create executable B that will gather relevant system information (with the help of GetLastInputInfo). Next, run executable B from executable A using this class which uses

Protecting a Windows Service from untrusted users

笑着哭i 提交于 2019-11-30 08:50:20
问题 How can I prevent users from tampering with, stopping or crashing a Windows Service that is doing work in the background that may take a while to complete? Upon receiving a stop request, the service should wait until the work is complete before stopping. There is the CanStop flag for services, but I'm not sure how to respond to the OnStop message. And if the user does try to crash the service, how can I prevent further tampering? Edit: Generalised question from parental control to any

detect shutdown in window service

微笑、不失礼 提交于 2019-11-30 08:39:40
i have a windows service that get user details and save the result into log text file. and, my problem is when i shut down or log off my system, i also would like to save the time that i down my system into that log file. but, i don't know how to do that. I checked the winproc method to detect shutdown operation but i was not able to use it on window service, on googling found it can be used with forms only. how can we detect user have clicked shutdown or log off and do some action. so,please give me some idea or suggestion on that. i have used it for logoff but on log entry is made when i

Windows service OnStop wait for finished processing

与世无争的帅哥 提交于 2019-11-30 08:31:34
I actually develop a Windows service in VS 2012 / .NET 4.5. The service is following the scheme of the code snippet below: Using a timer Executes some desired operation every couple of minutes. The process takes about 10 minutes to complete I use a single thread in the service What I am worried about is that if somebody stops the service via the management console, it might be just during the process that the service is doing. I have done some reading about stopping Windows service with request stop, but am a bit lost. Sometimes WorkerThreads are created, sometimes ManualResetEvents are

Win Service getting permission denied to Message Queuing

三世轮回 提交于 2019-11-30 08:09:58
问题 I have a WinService that can't start because NServiceBus throws "Service cannot be started. System.Messaging.MessageQueueException (0x80004005): Access to Message Queuing system is denied." This is on Windows 7 I have tried to run the service as: LocalSystem, Localservice, and NetworkService here is how I'm setting up NServiceBus private static IBus _serviceBus; private static AuditMessageHandler _messageHandler; public AuditQueueProcessor() { _messageHandler = new AuditMessageHandler();