windows-services

How to set up dependencies between windows-services on different servers in same domain

纵饮孤独 提交于 2019-12-18 09:05:22
问题 I have a situation where a windows service on one server should not be started until a windows service on a different server has started. What I'd like to do is set the service dependencies but the standard "sc <service1> depend= service2" doesn't seem to cater for this. I could wrap the service code in a TryUntilSuccesful() sort of call but I would like to know if there is a recomended way to set up dependencies for windows services across servers in the same domain. 回答1: Dependencies

Service failed to start error 1920

与世无争的帅哥 提交于 2019-12-18 07:22:27
问题 On some machine we have the following error at service install: "Service ... failed to start. Verify that you have sufficient privileges to start system services." Service is installed fine tho, just that it can't be started as Network Service from Services.msc. Service starts and runs good if started from console it's executable... Same thing happens with another service started as Local System. On other machines everything is fine. Service starts as network service with no problems. We

Service failed to start error 1920

不打扰是莪最后的温柔 提交于 2019-12-18 07:22:11
问题 On some machine we have the following error at service install: "Service ... failed to start. Verify that you have sufficient privileges to start system services." Service is installed fine tho, just that it can't be started as Network Service from Services.msc. Service starts and runs good if started from console it's executable... Same thing happens with another service started as Local System. On other machines everything is fine. Service starts as network service with no problems. We

Running a Java process in Windows even after the user is logged out

安稳与你 提交于 2019-12-18 06:13:27
问题 I have a batch file that starts a Java process in a Windows 2003 server. As per the security policy, the users of that machine are logged off forcefully, if the user is inactive for a certain period of time. The problem is that when the user is logged out, the process also dies. I scheduled a new task (Control Panel -> Scheduled Tasks) and selected the option of 'When my computer starts' and gave the user account details there. But it doesn't seem to have any effect, the user is still logged

running a batch file from C#

☆樱花仙子☆ 提交于 2019-12-18 05:51:20
问题 UPDATE ** STILL LOOKING FOR A CORRECT ANSWER ** I have the following code in my windows service and I want to run a batch file. I want the command prompt window up so I can see progress here is my code but my batch file code doesnt work using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Linq; using System.ServiceProcess; using System.Text; using System.IO; namespace Watcher { public partial class Watcher :

MySqlClient EndOfStreamException: Fatal error when attempting to read past the end of the stream

霸气de小男生 提交于 2019-12-18 05:19:06
问题 I have developed a windows service to read data from a csv and write them back to the database. After executing the program it will work fine until triggering an error after a few minutes when reached the below line cmd.ExecuteNonQuery(); Screenshot of the error: The data has been written to the database until this error pops up. It will take up to 2-3 minutes to trigger the error. I will include the related code chunk for this issue. public void Insert() { if (this.OpenConnection() == true)

How do I set the a windows service log on credentials?

淺唱寂寞╮ 提交于 2019-12-18 05:01:52
问题 How do I programmatically set the "Log On" credentials for an arbitrary Windows service using c# (wmi/interop is fine)? Note, my program is running as an administrator and I need the change to persist (for all subsequent service restarts) Ideally the method has the following sig: void SetWindowsServiceCreds(string serviceName, string username, string password) { // TODO write me } 回答1: [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Auto)] [return: MarshalAs(UnmanagedType

How can I show a Notification Area Balloon and Icon from a Windows Service?

旧时模样 提交于 2019-12-18 04:55:17
问题 I have a Windows Service that is always running when the user starts their workstation. This Windows Service is critical and I would like to show a Balloon Notification in the Notification Area when certain things happen such as the Service Stops, Starts, Restarts etc. For example: Also, is there a way to show a Notification Area Icon for my Windows Service? 回答1: The days of Windows services interacting directly with the desktop are over, so you have to find another way. What I have done is

How do I safely stop a C# .NET thread running in a Windows service?

吃可爱长大的小学妹 提交于 2019-12-18 04:37:08
问题 I am maintaining some code which looks something like this. It's a Windows service which does some work every 30 minutes. The ActualWorkDoneHere method takes about 30 seconds to run, but if it is stopped while running it can leave things in a bad state. What is the best way to prevent that from happening? Should I replace the While(true) with a boolean which is set to false in the onstop method (removing the thread Abort call)? Is there some way to tell if a thread is sleeping? namespace

How do we tell if a C++ application is launched as a Windows service?

谁说胖子不能爱 提交于 2019-12-18 04:13:07
问题 We have a console app which we launch from command prompt for debugging, but we also launch this as an NT service for production. Right now, the code has this logic: if (__argc <= 1) { assumeService(); } else { assumeForgound(); } Is there a better way to check how the process has been launched? We're an open source project, so every time we get a new Windows developer we have to explain that they must specify the -f arg to stop the app from connecting to the service controller. What about