Pat*_*ins 4 c# service .net-3.5
我希望能够在服务的安装中传递参数.我修改了从Installer继承的类的C#代码...我的问题是InstallUtil.exe不能用于参数(我不知道).
有什么建议吗?
我们有相同的场景,它的工作原理.您必须按如下方式传递参数
InstallUtil.exe /Param1="Value" /Param2="Value" "Path to your exe"
Run Code Online (Sandbox Code Playgroud)
然后,您要在安装程序上覆盖Install方法
public override void Install(System.Collections.IDictionary stateSaver)
{
var lParam1 = GetParam("Param1");
}
private string GetParam(string pKey)
{
try
{
if (this.Context != null)
{
if (this.Context.Parameters != null)
{
string lParamValue = this.Context.Parameters[pKey];
if (lParamValue != null)
return lParamValue;
}
}
}
catch (Exception)
{
}
return string.Empty;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11012 次 |
| 最近记录: |