Nat*_*han 70 .net windows-services
我有一个Windows服务可执行文件,我知道是用.NET编写的,我需要在不同的服务名称下安装以避免冲突.无论如何,安装都不提供指定服务名称.如果我只能访问二进制文件,那么当我用installutil安装它时,是否还要覆盖服务名称?
Jos*_*ger 102
你必须使用InstallUtil吗?以下是使用sc执行所需操作的命令:
sc create MyService binPath= "MyService.exe" DisplayName= "MyService"
sc description MyService "My description"
Run Code Online (Sandbox Code Playgroud)
参考:http://support.microsoft.com/kb/251192
Sac*_*nth 29
InstallUtil不允许您配置服务名称.我一直这样做
InstallUtil.exe /servicename="<service name>" "<path to service exe>"
Run Code Online (Sandbox Code Playgroud)
Vol*_*hat 24
添加方法以获取CustomService名称
private void RetrieveServiceName()
{
var serviceName = Context.Parameters["servicename"];
if (!string.IsNullOrEmpty(serviceName))
{
this.SomeService.ServiceName = serviceName;
this.SomeService.DisplayName = serviceName;
}
}
Run Code Online (Sandbox Code Playgroud)打电话给安装和卸载
public override void Install(System.Collections.IDictionary stateSaver)
{
RetrieveServiceName();
base.Install(stateSaver);
}
public override void Uninstall(System.Collections.IDictionary savedState)
{
RetrieveServiceName();
base.Uninstall(savedState);
}
Run Code Online (Sandbox Code Playgroud)installutil /servicename=”My Service [SysTest]” d:\pathToMyService\Service.exe
归档时间: |
|
查看次数: |
51425 次 |
最近记录: |