windows-services

Start Windows Service in C#

孤者浪人 提交于 2020-01-13 19:27:38
问题 I want to start a windows service that was just installed. ServiceBase[] ServicesToRun; if (bool.Parse(System.Configuration.ConfigurationManager.AppSettings["RunService"])) { ServicesToRun = new ServiceBase[] { new IvrService() }; ServiceBase.Run(ServicesToRun); } The IvrService code is: partial class IvrService : ServiceBase { public IvrService() { InitializeComponent(); Process myProcess; myProcess = System.Diagnostics.Process.GetCurrentProcess(); string pathname = Path.GetDirectoryName

A connection attempt failed because the connected party did not properly respond after a period of time or connected host has failed to respond

烂漫一生 提交于 2020-01-13 11:23:07
问题 I'm developing a windows service, that downloads images from a specific URL. The service runs correctly on my computer but when I install it in the server it does not download the image and it gives the following error: System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed

Install Windows service to run under user's credentials with ServiceAccount.User but don't prompt

China☆狼群 提交于 2020-01-13 11:20:51
问题 I have created a C# Windows Service and its accompanying Visual Studio Setup project that creates an installer. It successfully installs the service. When I choose any value from enum ServiceAccount apart from ServiceAccount.User , the service installs without prompting using the appropriate built-in user. What I am after is actually installing the service under current user's credentials . When I specify ServiceAccount.User , I get a prompt for a user name and password during installation.

Does ServiceBase.Run(ServiceBase[] ) method run all services in array asynchronously?

不想你离开。 提交于 2020-01-13 09:19:10
问题 ServiceBase[] servicesToRun; servicesToRun = new ServiceBase[] { new Service1(), new Service2() }; ServiceBase.Run(servicesToRun); How will this work? Will Service1 be run, and when its OnStart() is done, Service2's OnStart() will be run, or both of them will run at the same time? If that's the case, and I explicitly want Service1's OnStart to be done before running Service2.OnStart() , how would I go? Would this do the trick: ServiceBase.Run(new Service1()) ServiceBase.Run(new Service2())

How to detect user activity with a Java service running on Windows?

故事扮演 提交于 2020-01-13 09:18:06
问题 My goal is to create a system monitoring application using Java. I would like to know when a user is doing activity on a Windows PC. The result would be something like this: 8:00 - 8:15 activity 9:12 - 10:29 activity 12:24 - 15:34 activity I'm not interested in any other information (which key was pressed, application used, etc.). Only user activity. Is this even possible in Java? I plan to run my java application as a service. But as for getting events when a user uses the computer, I have

Serilog in Windows-Service not writing to logfile

ぐ巨炮叔叔 提交于 2020-01-13 07:32:09
问题 I am using Serilog within an TopShelf Service, logging to the console and a rolling file. When running the service in a console my messages are written to the logfile, but when I install the service and run it no logging occurs. Is there anything special I need to configure? The file is written to the binaries folder under ".\logs\log-{date}.txt". Best regards Gope 回答1: I had a very similar issue. In my case the problem was with relative paths. I just had to specify absolute path. Now it

Serilog in Windows-Service not writing to logfile

不问归期 提交于 2020-01-13 07:32:06
问题 I am using Serilog within an TopShelf Service, logging to the console and a rolling file. When running the service in a console my messages are written to the logfile, but when I install the service and run it no logging occurs. Is there anything special I need to configure? The file is written to the binaries folder under ".\logs\log-{date}.txt". Best regards Gope 回答1: I had a very similar issue. In my case the problem was with relative paths. I just had to specify absolute path. Now it

Is it good to have windows service or console application?

邮差的信 提交于 2020-01-12 16:21:34
问题 I have a tasks table in my db. I want to read data from this table and run tasks. Which one is better whether to have it as windows service or a console application running. The server on which this will be run will not be shutdown 回答1: You most likely want to use a windows service. Benefits: You can control the user (and the rights associated with this user account) which starts the process An automatically started process means the desktop need to be on, not user logged, for the service to

C# app hangs randomly when called from Process.Start()

心不动则不痛 提交于 2020-01-12 08:08:47
问题 I have a Windows service set up to manage custom .Net tasks. Organization is: -Windows Service monitors a schedule and starts a worker .exe as needed. -Worker .exe (lightweight winform app) uses a command line argument to pull up a DLL (plugin) and run some code. This has been working well for months. I recently migrated it to Server 2012 (from 2008 IIRC) - this may be unrelated but it's hard to tell. Since some time after the migration, I've encountered an issue where the worker .exe "starts

wmic via .NET or C#

♀尐吖头ヾ 提交于 2020-01-11 13:23:29
问题 All, Please forgive my ignorance of C#/.NET, I am absolutely new to both (mostly Java, C/C++) and find myself tasked with creating some code that performs the same thing as the "wmic qfe" and "wmic os" commands available at the DOS prompt. Can this be done? If so, any help is appreciated. I am trying to working my way through the System.Management.Instrumentation namespace since wmic is an acronym for Windows Management Instrumentation Command (according to Google), but have as yet to