windows-services

How to start /stop a windows service through a Windows Form application

蹲街弑〆低调 提交于 2019-12-25 03:25:00
问题 I wish to start and stop another Windows Service application via my WIndows Form application. Ons tart of my application I wish to start the Windows service, and on application exit I wish to stop the service. How can this be achieved? 回答1: You want to use the ServiceController class. Initialize it with your service name, and call Start() and Stop() methods. using System.ServiceProcess; ServiceController sc = new ServiceController("My service name"); if (sc.Status == ServiceControllerStatus

Add FileSystemWatcher and Timer to a .Net 2.0 windows service

折月煮酒 提交于 2019-12-25 03:08:27
问题 Anyone see any potential problems adding a FileSystemWatcher and a Timer into my derived ServiceBase class?? Malcolm 回答1: Just be sure to wrap the events for each in a try-catch as they will run on threads from the Thread Pool. If there is an exception during the processing of that event your service may stop running unexpectedly. You should also keep the processing in the FileSystemWatcher Event to a minimum, for instance, just add the file path to a queue and then have one of your timers or

Start service automatically when windows start

不问归期 提交于 2019-12-25 03:06:54
问题 I install a service in windows server 2008 r2 , and want to start it when windows start class Program : ServiceBase { ... static void Main(string[] args) { ServiceBase.Run(new Program()); } public Program() { this.ServiceName = "ABPS"; } protected override void OnStart(string[] args) { base.OnStart(args); this.start();//a method that start works } ... 回答1: you should add installer to your application. To determine how your service will be started, click the ServiceInstaller component and set

FileSystemWatcher Fails to access network drive

吃可爱长大的小学妹 提交于 2019-12-25 02:40:28
问题 I am trying to run a file watcher over some server path using windows service. I am using my windows login credential to run the service, and am able to access this "someServerPath" from my login. But when I do that from the FileSystemWatcher it throws: The directory name \someServerPath is invalid" exception. var fileWatcher = new FileSystemWatcher(GetServerPath()) { NotifyFilter=(NotifyFilters.LastWrite|NotifyFilters.FileName), EnableRaisingEvents=true, IncludeSubdirectories=true }; public

C# Windows Service — the service on local computer started and then stopped?

柔情痞子 提交于 2019-12-25 02:25:17
问题 I am trying to create my first Windows Service, but so sad... after I started the service manually from services.msc, the message 'the service on local computer started and then stopped. some services stop automatically is they have no work to do' I am sure there must be some mistake in my code... namespace ConvertService { public partial class Service1 : ServiceBase { public Service1() { this.ServiceName = "ConvertService"; this.EventLog.Log = "Application"; } static void main() {

.NET Service to monitor web page changes

末鹿安然 提交于 2019-12-25 02:19:37
问题 I want to create a service that will monitor changes to web pages i.e. the page content has been updated. I am trying to think of the best way to achieve this and at present I am considering a couple of options. Note that there could be hundreds of pages to monitor and the interval for checking could be seconds or hours (configurable). Create a windows service for each page to monitor Create a windows service that spawns a thread for each page to monitor Now, I am concerned which of these is

How to launch vbs script after internet connection is detected in windows xp? [closed]

房东的猫 提交于 2019-12-25 02:15:03
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . How can i launch a vbs script after the wifi connection has been stablished? Thanks in advance. 回答1: You could launch a VBScript that loops looking for a response from an internet site/device/whatever. When it sees it, it will execute code, otherwise it will try for up to XX

libcurl crashes in a Windows service

廉价感情. 提交于 2019-12-25 01:43:39
问题 My service receives data from some processes, parses it, and sends an HTTP post to my PHP server. When I started writing the code, it was an ordinary 64-bit program. After I finished, I converted it to a service, but some crashes happen when the service tries to send the data. The reason isn't clear, as I use libcurl in other places in the service without problems. My receiver is something like this: while (true) { memset(pipe_buffer, 0, 10000); cres = ReadFile(pipe, pipe_buffer, 10000, &read

How can I start a browser from a windows service

醉酒当歌 提交于 2019-12-25 00:39:19
问题 I need to create a windows service that when launced open a specific URL. What I did is to override the onStart() method by adding the following lines : protected override void OnStart(string[] args) { eventLog1.WriteEntry("Browser must start " + DateTime.Now); string targetURL = "http://www.mysite.com"; System.Diagnostics.Process.Start(targetURL); } However this thing doesn`t work . :(( Thing is that it does write the log .than means that onStart Anybody has any ideas???? 回答1: The service is

AccessViolation exception with TAPI and Windows Service

萝らか妹 提交于 2019-12-25 00:19:48
问题 I will try to make this as short and sweet as I possibly can. I have created an application that is used by my company to call about 2000 different phone numbers each day (used to contact very old devices we have deployed around the US), When I run the application as a Windows Application (written using C# and JulMar ITAPI3 wrapper) the application seems to run rock solid with no issues which tells me at least my code is mostly right.... The problem I am encountering is when I run the same