Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 以编程方式启动Windows服务_C#_Windows Services - Fatal编程技术网

C# 以编程方式启动Windows服务

C# 以编程方式启动Windows服务,c#,windows-services,C#,Windows Services,我设置了一个quartz.NET项目,该项目应该计划每隔一段时间运行一次windows服务。目前,我正在尝试启动以下服务: Process.Start("path/app.exe"); 但我得到的是:“无法从命令行或调试器启动服务。必须先安装Windows服务,然后使用ServerExplorer、Windows服务管理工具或NET start命令启动 因此,我想知道,首先,这会在发布模式下消失吗?或者我必须找到另一种方法来实现这一点。无论哪种方法,我都需要能够以编程方式安排这项工作。消息告诉

我设置了一个quartz.NET项目,该项目应该计划每隔一段时间运行一次windows服务。目前,我正在尝试启动以下服务:

Process.Start("path/app.exe");
但我得到的是:“无法从命令行或调试器启动服务。必须先安装Windows服务,然后使用ServerExplorer、Windows服务管理工具或NET start命令启动


因此,我想知道,首先,这会在发布模式下消失吗?或者我必须找到另一种方法来实现这一点。无论哪种方法,我都需要能够以编程方式安排这项工作。

消息告诉您一些启动服务的方法,但这些不是从C#开始的正确方法。有一种更好的方法:使用de>System.ServiceProcess.ServiceController类启动服务。

该消息告诉您一些启动服务的方法,但这些方法在C#中并不正确。有一种更好的方法:使用
System.ServiceProcess.ServiceController
类启动服务