Windows 7 如何在没有Visual Studio的情况下在windows 7上安装服务?

Windows 7 如何在没有Visual Studio的情况下在windows 7上安装服务?,windows-7,windows-services,Windows 7,Windows Services,安装windows服务:Visual Studio中有一个util:InstallUtil.exe。 如果我有一个服务MyService.exe,并且想在没有Visual Studio的windows 7上安装它,我如何安装它?一种方法是使用sc.exe,它是操作系统的一部分。例如: sc create **ServiceName** start= auto binPath= "c:\mydir\myService.exe" 其中binPath是包含服务的exe文件 如果您不希望启动类型=自动

安装windows服务:Visual Studio中有一个util:InstallUtil.exe。
如果我有一个服务MyService.exe,并且想在没有Visual Studio的windows 7上安装它,我如何安装它?

一种方法是使用sc.exe,它是操作系统的一部分。例如:

sc create **ServiceName** start= auto binPath= "c:\mydir\myService.exe"
其中binPath是包含服务的exe文件

如果您不希望启动类型=自动,则可以在windows的命令行上使用net start和net stop命令分别启动和停止服务。

您可以尝试NSSM(非吸吮式服务管理器),以防“sc”无法正常工作


不久前,我在Go中构建了一个服务,无法在“sc”下运行,nssm工作得很好。

您可以在“C:\Windows\Microsoft.NET\Framework\v2.0.50727”找到installUtil.exe,从CMD提示符启动,并将路径添加到您的服务中。

无法让nssm在我的W7上运行。它总是把自己的路径作为我放在路径框中的程序的路径。必须手动使用上面的sc示例。这非常有效。要获取sc参数的列表,只需执行sc。ServiceName前面的两个*将导致ServiceName出现在C:\Windows\System32\compmgmt.msc列表的顶部。要删除服务,请使用sc delete ServiceName。您将聚焦列表并使用刷新菜单项查看compmgmt.msc中的更改。

示例:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe/u“MyService.exe”C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe“MyService.exe”NET start“MyService”