【问题标题】:How to install a service on windows 7 without Visual Studio?如何在没有 Visual Studio 的 Windows 7 上安装服务?
【发布时间】:2012-12-12 20:09:39
【问题描述】:

安装 Windows 服务:Visual Studio 中有一个实用程序:InstallUtil.exe。 如果我有一个服务 MyService.exe 并且想在没有 Visual Studio 的 Windows 7 上安装它,我该如何安装它?

【问题讨论】:

    标签: windows-7 windows-services


    【解决方案1】:

    一种方法是使用 sc.exe,它是 OS 的一部分。示例:

    sc create **ServiceName** start= auto binPath= "c:\mydir\myService.exe"
    

    其中 binPath 是包含您的服务的 exe 文件。

    如果你不想启动类型=自动,那么你可以在windows的命令行上使用net start和net stop命令来分别启动和停止服务。

    【讨论】:

      【解决方案2】:

      当“sc”不能按预期工作时,您可以尝试 NSSM(非吸吮服务管理器)。 http://nssm.cc

      我不久前在 Go 中构建了一项服务,但无法在“sc”下运行,nssm 运行良好。

      【讨论】:

        【解决方案3】:

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

        【讨论】:

        • 示例: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"
        【解决方案4】:

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

        【讨论】:

          猜你喜欢
          • 2011-02-05
          • 1970-01-01
          • 1970-01-01
          • 2014-04-05
          • 2011-10-05
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多