windows-services

How to get the status of a service programmatically (Running/Stopped)

六月ゝ 毕业季﹏ 提交于 2019-12-21 17:54:31
问题 I need to get the status of Windows "print spooler" service in my C++ application. 回答1: Use QueryServiceStatus or QueryServiceStatusEx. There are plenty of examples on the web on how these are used. 回答2: The function that @shikarssj provided is working perfectly, it only requires admin rights when loading the service. Here is a version that does not ask for full permission: #include <Windows.h> int GetServiceStatus( const char* name ) { SC_HANDLE theService, scm; SERVICE_STATUS m_SERVICE

How to get the status of a service programmatically (Running/Stopped)

放肆的年华 提交于 2019-12-21 17:53:37
问题 I need to get the status of Windows "print spooler" service in my C++ application. 回答1: Use QueryServiceStatus or QueryServiceStatusEx. There are plenty of examples on the web on how these are used. 回答2: The function that @shikarssj provided is working perfectly, it only requires admin rights when loading the service. Here is a version that does not ask for full permission: #include <Windows.h> int GetServiceStatus( const char* name ) { SC_HANDLE theService, scm; SERVICE_STATUS m_SERVICE

Forcing windows to wait for a service to stop when it is shutting down

我的梦境 提交于 2019-12-21 12:21:31
问题 I'm having an issue that I can't figure out regarding a Windows Service I have written in C#. What I am trying to do is wait for a specified period for a child process to terminate before I am forced to kill it and stop the service. I have set my timeout for anywhere from 5 to 15 seconds and my service waits the appropriate amount of time and then kills the child and stops when I stop it via the mmc service window. However if I shutdown the computer my service gets blown away before it is

Windows Service Deployment

有些话、适合烂在心里 提交于 2019-12-21 12:17:28
问题 I am currently deploying my windows services manually on the server. One time Steps: Install Location on server hosting windows server -> D:\InstallDir Copied windows Service related files into this folder Created a batch file to Install Windows Service ( InstallUtil.Exe ) and another batch file to uninstall windows service and copied in the install folder Installed windows service using the install batch file Here are the steps I perform to upgrade: Take backup of existing Install folder (to

How do Windows services behave when entering/waking up from sleep or hibernate modes?

社会主义新天地 提交于 2019-12-21 11:32:27
问题 I have a service written in C# that does not seem to come down cleanly when the computer enters sleep mode. The user needs to manually stop and restart the service to retain functionality. I know what the issue is but I am not sure where to fix it. How do Windows services behave when going into/come out of sleep and hibernate? 回答1: How do services react to power events? Really, it depends . In your service you can handle the hibernate/suspend/etc events by handling it in your service

How do Windows services behave when entering/waking up from sleep or hibernate modes?

浪子不回头ぞ 提交于 2019-12-21 11:32:10
问题 I have a service written in C# that does not seem to come down cleanly when the computer enters sleep mode. The user needs to manually stop and restart the service to retain functionality. I know what the issue is but I am not sure where to fix it. How do Windows services behave when going into/come out of sleep and hibernate? 回答1: How do services react to power events? Really, it depends . In your service you can handle the hibernate/suspend/etc events by handling it in your service

Running a C# console application as a Windows service

不打扰是莪最后的温柔 提交于 2019-12-21 11:29:10
问题 I have a basic C# console application that I would like to run as a Windows Service. I have created the Windows service using sc create . This worked fine, and I can see my service under services.msc . When I try and start this service I get the following error: Could not start the PROJECT service on Local Computer. Error 1053: The service did not respond to the start or control request in a timely fashion.` I read that this might be due to the service code taking longer than 30000 ms to

windows could not start service on local computer error 5 access is denied

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-21 09:09:23
问题 After debugging and installing windows service in windows 8 I have error when I try to start a windows service :"The Windows could not start service on local computer Error 5 Access is denied" .While attempting fist answer from this link i found that NETWORK SERVICE account doesn't exist in the list of user names for assigning the correct permissions in windows 8 .How i can solve this problem using windows 8? 回答1: Right click in the service in Window Services and go to Properties . Then go to

Windows Service won't automatically start after reboot [duplicate]

混江龙づ霸主 提交于 2019-12-21 07:27:22
问题 This question already has answers here : “A timeout was reached while waiting for the service to connect” error after rebooting (6 answers) Closed 6 years ago . My automatically starting windows service fails to start only on reboot. I have a windows service created in C# and installed via a Wix created installer. The service is set up to start automatically. The service is installed and run under the NT AUTHORITY\NETWORK SERVICE. When the service is started, it first makes an external web

Get the PID of a Windows service

℡╲_俬逩灬. 提交于 2019-12-21 07:07:26
问题 Could anyone help me to know how to get the PID of a Windows service? I need to get the PID in order to run the following command: Process.Start(new ProcessStartInfo { Filename = "cmd.exe", CreateNoWindow = true, UseShellExecute = false, Arguments = string.Format("/c taskkill /pid {0} /f", pidnumber) }); 回答1: Assuming you know the name of the EXE the service uses and there is exactly one of them: int procID = Process.GetProcessesByName("yourservice")[0].Id; The method Process