use*_*642 2 service installutil powershell-2.0
我正在尝试编写一个 powershell 脚本来安装接受安装参数的服务。
以下内容在命令提示符下有效
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"
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试从 Powershell 运行 installutil 时,它不起作用并给了我一个异常
Powershell脚本
$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]..
Run Code Online (Sandbox Code Playgroud)
如何将参数传递给 installutil?任何帮助表示赞赏。
使用 Start-Process cmdlet 使其正常工作
\n\n$x=""\n\n$x = "/ControllerGroup=$controllerGroup\xe2\x80\x9d, \xe2\x80\x9c/username=$Username\xe2\x80\x9d , "/password=$Password", "/unattended" , $ServiceExecutablePath\n\nStart-Process \xe2\x80\x93FilePath C:\\WINDOWS\\Microsoft.NET\\Framework\\v4.0.30319\\InstallUtil.exe \xe2\x80\x93ArgumentList $x \xe2\x80\x93NoNewWindow\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
8013 次 |
| 最近记录: |