【问题标题】:Silently install multiple exe installers in one folder in PowerShell在 PowerShell 的一个文件夹中静默安装多个 exe 安装程序
【发布时间】:2019-04-11 17:10:44
【问题描述】:

我一直在学习 powershell,我想知道例如在“D:\installers”文件夹中,我假设有 15 个安装程序(全部为 inno 安装程序),是否可以无声运行安装所有这些exe?

到目前为止,我已经学会了如何在静默状态下只运行一个安装程序,它工作得非常好。我只是不知道如何处理多个 exes

Start-Process -Wait -FilePath 'D:\Installers\Installer.exe' -ArgumentList '/silent' -PassThru 仅适用于一名安装人员

【问题讨论】:

  • 请阅读about_foreach 的完整帮助,包括示例。这会让你开始。

标签: powershell


【解决方案1】:
$installers = get-childitem "D:\Installers"  -Filter "*Driver*.exe"
foreach($inst in $installers)
{
    Start-Process -Wait -FilePath ($inst.FullName) -ArgumentList '/silent' -PassThru
}

Get-Childitem 可用于获取安装程序,使用 foreach 可以查看结果

【讨论】:

  • 是的,这正是我想要的!非常感谢!还有一件事。是否可以应用类似的东西:从此文件夹中静默安装 exe,名称中只有“驱动程序”?我知道它可能可以用 ``` | Where-Object Name -like 'Drivers' | ```对吗?但我不确定将它放在代码中的哪个位置,或者它是否真的可以工作
【解决方案2】:

您可以按照自己的路径修改路径并将其复制到powershell(确保以管理员身份运行)。 Powershell 会依次运行它们。

Start-Process -FilePath 'D:\Installers\Installer1.exe' -Wait

Start-Process -FilePath 'D:\Installers\Installer2.exe' -Wait

Start-Process -FilePath 'D:\Installers\Installer3.exe' -Wait

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-02
    • 1970-01-01
    • 2019-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-17
    相关资源
    最近更新 更多