问题描述
在远程机器上安装用 c# 编写的 windows 服务(以标准方式)的最佳方法是什么,我需要提供它应该运行的用户名和密码?
what is the best way to install a windows service written in c# (in the standard way) on a remote machine, where i need to provide the username and password it should run as?
作为集成测试的一部分,我将从 msbuild 运行它.
i am going to run it from msbuild as part of integration tests.
我没有 msi,也不想创建一个.
i don't have an msi and i don't want to create one.
推荐答案
你可以使用sc 命令.
sc.exe \remotecomputer create newservice binpath= c:windowssystem32newserv.exe start= auto obj= domainusername password= pwd
(注意等号后面的空格很重要)
(note the spaces after the equals signs are important)
creates a service entry in the registry and service database. syntax: sc create [service name] [binpath= ]... create options: note: the option name includes the equal sign. type= (default = own) start= (default = demand) error= (default = normal) binpath= group= tag= depend= obj= (default = localsystem) displayname= password=