关于使用命令提示安装Windows服务的困惑

时间:2008-11-09 03:06:26

标签: windows-services

我在.NET 2.0中设计了一个简单的Windows服务。

我正在尝试在本地计算机上部署它。我已切换到设计视图,并设置ServiceInstaller和ServiceProcessInstaller对象。有一个Project Installer。我还将Windows服务包装到.NET安装项目中并安装它,在指定目录中保留.exe。

我已经启动了cmd并进入了installutil的路径。这工作正常,但后来我在Visual Studio命令提示符下输入了instalallutil和服务的完整路径,这不起作用(我也尝试过installutil / i以及绝望的各种事情)。权限是本地系统(扩展)。

任何想法我做错了什么?对于那些安装了Windows服务的人来说,安装服务的方法是什么?

由于

4 个答案:

答案 0 :(得分:2)

我们实际上是在应用程序中创建了一个安装程序。它是一个控制台应用程序,具有安装/卸载服务器以及作为服务运行或在控制台模式下运行的命令行。

有关详细信息,请参阅Self Installing Service上的这篇文章。我喜欢这种方法,因为它提供了灵活性。

答案 1 :(得分:1)

DESCRIPTION:
        SC is a command line program used for communicating with the
        NT Service Controller and services.
USAGE:
        sc  [command] [service name]  ...

        The option  has the form "\\ServerName"
        Further help on commands can be obtained by typing: "sc [command]"
        Commands:
          query-----------Queries the status for a service, or
                          enumerates the status for types of services.
          queryex---------Queries the extended status for a service, or
                          enumerates the status for types of services.
          start-----------Starts a service.
          pause-----------Sends a PAUSE control request to a service.
          interrogate-----Sends an INTERROGATE control request to a service.
          continue--------Sends a CONTINUE control request to a service.
          stop------------Sends a STOP request to a service.
          config----------Changes the configuration of a service (persistant).
          description-----Changes the description of a service.
          failure---------Changes the actions taken by a service upon failure.
          qc--------------Queries the configuration information for a service.
          qdescription----Queries the description for a service.
          qfailure--------Queries the actions taken by a service upon failure.
          delete----------Deletes a service (from the registry).
          create----------Creates a service. (adds it to the registry).
          control---------Sends a control to a service.
          sdshow----------Displays a service's security descriptor.
          sdset-----------Sets a service's security descriptor.
          GetDisplayName--Gets the DisplayName for a service.
          GetKeyName------Gets the ServiceKeyName for a service.
          EnumDepend------Enumerates Service Dependencies.

        The following commands don't require a service name:
        sc   
          boot------------(ok | bad) Indicates whether the last boot should
                          be saved as the last-known-good boot configuration
          Lock------------Locks the Service Database
          QueryLock-------Queries the LockStatus for the SCManager Database
EXAMPLE:
        sc start MyService

答案 2 :(得分:0)

这是另一个特定于.NET服务的参考。

http://bytes.com/forum/thread739857.html

答案 3 :(得分:0)

我在我的安装包中调用installutil,它对我很有用。

如果您在运行installutil时发布了错误消息,那就太棒了。