c# - 通过 installutil 将参数传递给服务安装程序

标签 c# powershell

我正在尝试编写一个 power shell 脚本来安装服务,但该服务需要传递给它的额外命令行参数。我无法将其传递。

这里是使用参数的服务安装器;

this.serviceInstaller.ServiceName = string.Format("My brill service {0}",this.Context.Parameters["environment"])

我尝试过以两种方式传递参数;

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe "C:\foo\bar.exe /environment:tomtest"

(这给出了错误“url 上的目录无效”)

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe /environment:tomtest "C:\foo\bar.exe"

(这只是改变服务名称)

有什么想法吗?谢谢

最佳答案

我离得很近。必须使用等号 = 来分配参数值(不是冒号 :):

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe /environment=tomtest "C:\foo\bar.exe"

关于c# - 通过 installutil 将参数传递给服务安装程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12693578/

相关文章:

exception - PowerShell 运行时异常 - "could not load file or assembly"

c# - 如何在 LINQ 中查找 `Distinct` 记录?

c# MapHttpAttibuteRoutes 不能使用具有不同参数的相同操作?

c# - “Error HRESULT E_FAIL has been returned from a call to a COM component” 窗体 c#

c# - "Can' t 在 Xamarin Forms 项目中找到“NS*Types(例如 NSFileManager 或 NSUrl)

c# - gmail联系人的邮政地址解析

azure - Invoke-AzVMRunCommand - 错误处理的最佳实践?

Azure powershell Runbook 不显示任何输出

Powershell 无权访问网络共享

Azure 的 New-AzureRmHDInsightCluster 命令不接受记录的 ComponentVersion 选项