windows-services

How to write c# service that I can also run as a winforms program?

微笑、不失礼 提交于 2019-11-27 12:33:49
问题 I have a windows service written in C# that acts as a proxy for a bunch of network devices to the back end database. For testing and also to add a simulation layer to test the back end I would like to have a GUI for the test operator to be able run the simulation. Also for a striped down version to send out as a demo. The GUI and service do not have to run at the same time. What is the best way to achieve this duel operation? Edit: Here is my solution combing stuff from this question , Am I

.NET Windows Service needs to use STAThread

和自甴很熟 提交于 2019-11-27 12:29:06
I have created a Windows Service that will be calling out to some COM components, so I tagged [STAThread] to the Main function. However, when the timer fires, it reports MTA and the COM calls fail. How can I fix this? using System; using System.Diagnostics; using System.ServiceProcess; using System.Threading; using System.Timers; namespace MyMonitorService { public class MyMonitor : ServiceBase { #region Members private System.Timers.Timer timer = new System.Timers.Timer(); #endregion #region Construction public MyMonitor () { this.timer.Interval = 10000; // set for 10 seconds this.timer

Relative Path issue with .Net Windows Service..?

巧了我就是萌 提交于 2019-11-27 12:24:36
问题 I have a windows service which is trying to access an xml file from the Application directory. Windows Service Installed directory : C:\Services\MyService\MyService.exe Path of the xml file : C:\Services\MyService\MyService.xml I am trying to access the file using the following code. using (FileStream stream = new FileStream("MyService.xml", FileMode.Open, FileAccess.Read)) { //Read file } I get the following error. "Can not find file : C:\WINDOWS\system32\MyService.xml" My service is running

What's the best way to watchdog a desktop application?

自作多情 提交于 2019-11-27 12:05:50
I need some way to monitor a desktop application and restart it if it dies. Initially I assumed the best way would be to monitor/restart the process from a Windows service, until I found out that since Vista Windows services should not interact with the desktop I've seen several questions dealing with this issue, but every answer I've seen involved some kind of hack that is discouraged by Microsoft and will likely stop working in future OS updates. So, a Windows service is probably not an option anymore. I could probably just create a different desktop/console application to do this, but that

Windows Service with .NET Core [closed]

流过昼夜 提交于 2019-11-27 11:33:59
问题 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 last year . Is there a way to develop a windows service (able to start on boot etc...) with .NET Core? All tutorials and instructions I find utilize System.ServiceProcess.ServiceBase which can not be found and added for some reason in Visual Studio 2015? I also try to avoid using 3rd party

Windows Service to Azure?

本小妞迷上赌 提交于 2019-11-27 11:29:28
问题 I've written a Windows Service in C# that does a whole bunch of background admin tasks on the database. Now my customer wants to migrate the whole shebang to Azure. I know next to nothing about Azure, and my customer says you can't run a Windows Service on Azure. I've googled for this topic and come out with a few very specific case studies of what somebody did to move their Windows Service to Azure, assuming a fairly high level of understanding of how Azure works, but no general articles

Run a Windows Service as a console app

ⅰ亾dé卋堺 提交于 2019-11-27 11:29:03
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..... 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 you can open up the list of Services to start it. EG: Right click 'My Computer' Click on 'Manage' Open up

Start Windows Service programmatically

自闭症网瘾萝莉.ら 提交于 2019-11-27 11:26:25
问题 I am having an issue with an application that I am creating. I am trying to start a windows service through my C# app. When I click my start button, it looks like everything goes through but when I log into the server, the service still does not show that it is running. However, the second time I run it, I get an exception that says the instance of the service is already running. Again when I log into the server, the service appears to be stopped. Has anyone ever seen this? Here is my code.

start windows service from java

让人想犯罪 __ 提交于 2019-11-27 10:54:06
问题 How can we start/stop a Windows Service from Java? For example, I would like to start and stop the mysql Windows Service from Java. If start/stop is possible, then is it possible to know whether the service is started successfully or not? 回答1: You can formulate a Command Prompt script to start, stop, and check status on a service using a String Array: // start service String[] script = {"cmd.exe", "/c", "sc", "start", SERVICE_NAME}; // stop service String[] script = {"cmd.exe", "/c", "sc",

Stopping/Starting a remote Windows service and waiting for it to open/close

邮差的信 提交于 2019-11-27 10:39:01
The top answer to this question tells me how to stop/start a remote service. Great. Now, all I need is to wait for the actual stop/start to complete. So, what I'm looking for is a dos command to: Start a service, should return only after the service is started (or after a timeout, raising error level) Stop a service, return only after the service is stopped Eric Falsken I created a set of batch scripts that use sc.exe to do just this. They are attached below. To run these scripts, you should be a user with administration rights on the target machine and running this from a computer that is a