首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Powershell中的InstallUtil安装服务(接受安装参数)

使用Powershell中的InstallUtil安装服务(接受安装参数)
EN

Stack Overflow用户
提问于 2013-10-16 21:56:04
回答 1查看 7.6K关注 0票数 2

我正在尝试编写一个powershell脚本来安装一个接受安装参数的服务。

以下内容在命令提示符中有效

代码语言:javascript
复制
C:\Windows\Microsoft.NET\Framework\v4.0.30319>installutil.exe /ControllerGroup=Delivery     /username=userl /password=pwd /unattended    "C:\DocumentProcessingPlatform\Dpp.Service\bin\Debug\Dpp.Service.exe"

但是,当我尝试从Powershell运行installutil时,它不起作用,并给了我一个异常

Powershell脚本

代码语言:javascript
复制
$sn = " ControllerGroup=$line /username=$Username /password=$Password /unattended  ""$ServiceExecutablePath""" 
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe $sn

Exception occurred while initializing the installation:
System.ArgumentException: File  ControllerGroup=Delivery /username=usr /password=pwd /unattended C:\DocumentProcessingPlatform\Dpp.Service\bin\Debug\Dpp.Service.exe does not exist. If this parameter is used as an installer option, the format must be
/key=[value]..

如何将参数传递给installutil?任何帮助都是非常感谢的。

EN

回答 1

Stack Overflow用户

发布于 2013-11-19 19:30:44

通过使用Start-Process cmdlet使其正常工作

代码语言:javascript
复制
$x=""

$x = "/ControllerGroup=$controllerGroup”, “/username=$Username” , "/password=$Password", "/unattended" , $ServiceExecutablePath

Start-Process –FilePath C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe –ArgumentList $x –NoNewWindow
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19405391

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档