windows-services

Run a Windows Service as a console app

假装没事ソ 提交于 2019-11-26 15:35:32
问题 I want to debug a Windows service but it pops an error message saying Cannot start service from the command line or a debugger. A windows service must be installed using installutil.exe and then started with the Server explorer, windows services Administrative tools or the NET start command. I don't really have any idea about this error..... 回答1: Before a Windows Service can run, it has to be "installed" first using installutil. EG: C:\installutil -i c:\path\to\project\debug\service.exe Then

How can a Windows Service start a process when a Timer event is raised?

女生的网名这么多〃 提交于 2019-11-26 15:28:47
I have created a Windows Service with Timer and in firing event of timer.Elapsed I am creating a process ( System.Diagnostics.Process.Start(exe path) ) at interval of 5 seconds. But this process does not get created on the firing of an event. Is there any other way of doing this? Thanks in advance. private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { Process pr = new Process(); pr.StartInfo.FileName = @"C:\Program Files\Messenger\msmsgs.exe"; pr.StartInfo.WindowStyle = ProcessWindowStyle.Normal; pr.StartInfo.CreateNoWindow = false; pr.Start(); } You're adding

Installing Windows Service programmatically

和自甴很熟 提交于 2019-11-26 15:14:06
问题 How do I install a Windows Service programmatically without using installutil.exe? 回答1: You can install the service by adding this code (in the program file, Program.cs) to install itself when run from the commandline using specified parameters: /// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { if (System.Environment.UserInteractive) { if (args.Length > 0) { switch (args[0]) { case "-install": { ManagedInstallerClass.InstallHelper(new

Run batch file as a Windows service

邮差的信 提交于 2019-11-26 14:57:08
In order to run one application, a batch file has to be kicked off (which does things like start Jetty, display live logs, etc). The application will work only if this batch file is running. I am hence forced to have this batch file running and not logout from the Windows server. Can this batch file be run as a service? I am experimenting with one of the suggestions from a similar question . NSSM is totally free and hyper-easy, running command prompt / terminal as administrator: nssm install "YourCoolServiceNameLabel" then a dialog will appear so you can choose where is the file you want to

show a windows form from a window service

隐身守侯 提交于 2019-11-26 14:55:58
问题 i am creating a window service. my requirement is to display window form from window NT service on particular interval. For testing purpose , i just want to display the form on service start: protected override void OnStart(string[] args) { eventLog1.WriteEntry("In OnStart -before form show"); Messager_Form obj = new Messager_Form(); obj.Show(); // System.Diagnostics.Process.Start("calc.exe"); eventLog1.WriteEntry("In OnStart -after form show"); // timer1.Start(); } it not working. Neither

.NET console application as Windows service

浪尽此生 提交于 2019-11-26 14:53:29
I have console application and would like to run it as Windows service. VS2010 has project template which allow to attach console project and build Windows service. I would like to not add separated service project and if possible integrate service code into console application to keep console application as one project which could run as console application or as windows service if run for example from command line using switches. Maybe someone could suggest class library or code snippet which could quickly and easily transform c# console application to service? VladV I usually use the

Delphi 2009: How to communicate between Windows service & desktop application under Vista?

心已入冬 提交于 2019-11-26 13:55:03
问题 How can a desktop application communicate with a Windows service under Vista/Windows2008/Windows7? The application needs to send small strings to the service and receive string responses back. Both are written in Delphi 2009. (Please provide sample code also) 回答1: The way to go is named pipes, you'll probably have to take a look at the communication across different Integrity levels. This article explores how to do this in vista. Although it's written in c++ it's just basic Windows API calls,

How can I restart a windows service programmatically in .NET

谁说胖子不能爱 提交于 2019-11-26 13:22:06
问题 How can I restart a windows service programmatically in .NET? Also, I need to do an operation when the service restart is completed. 回答1: Take a look at the ServiceController class. To perform the operation that needs to be done when the service is restarted, I guess you should do that in the Service yourself (if it is your own service). If you do not have access to the source of the service, then perhaps you can use the WaitForStatus method of the ServiceController . 回答2: This article uses

windows service startup timeout

荒凉一梦 提交于 2019-11-26 12:38:09
问题 Is there a way to set a different value for service startup timeout per service? I can change it using the ServicesPipeTimeout registry key, but it\'s per machine (http://support.microsoft.com/kb/824344). At the moment the only thing I thought about was to do all the time-consuming startup actions in a different thread. 回答1: It's good practice to finish starting your service as fast as possible. So, during the start state, do only what you absolutely need to acknowledge it started

Install a .NET windows service without InstallUtil.exe

北慕城南 提交于 2019-11-26 12:35:51
I have a standard .NET windows service written in C#. Can it install itself without using InstallUtil? Should I use the service installer class? How should I use it? I want to be able to call the following: MyService.exe -install And it will have the same effect as calling: InstallUtil MyService.exe Marc Gravell Yes, that is fully possible (i.e. I do exactly this); you just need to reference the right dll (System.ServiceProcess.dll) and add an installer class... Here's an example: [RunInstaller(true)] public sealed class MyServiceInstallerProcess : ServiceProcessInstaller { public