powershell - 使用powershell脚本安装软件

标签 powershell powershell-2.0

我正在尝试使用 PowerShell v2.0 脚本为我的一个 POC 安装 Notepad++ 软件。我需要在我当前的项目中安装客户端的软件。当我运行以下脚本时,出现错误。

Start-Process 'C:\Users\kirnen\Desktop\A\npp.7.5.Installer.exe'-InstallerParameters "/S" `
-RegistryKey HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Notepad++ `
-RegistryName DisplayVersion -RegistryValue 7.5

由于我对 powershell 脚本非常陌生,您能帮忙吗?上面的代码是否正确,还是我需要更改其他任何内容才能安装该软件?

最佳答案

有几种不同的方法可以做到这一点。你这样做的方式很好,但我认为你并不真正想要所有这些安装参数。
Start-Process 'C:\Users\kirnen\Desktop\A\npp.7.5.Installer.exe' "/S"/S part 意味着您需要静默安装,因此您不会看到安装向导,也无法选择任何选项。不是坏事,只要确定这就是你想要的。脱下"/S"如果您想按照图形安装向导进行操作。

而不是 Start-Process您也可以使用 cmd /c而只是 & .这些都有其优点和缺点。坚持 Start-Process目前。

最后一件事,对于许多 .exe 文件,您可以使用 /help 跟踪它们。或 /?获取他们的命令行开关列表。

关于powershell - 使用powershell脚本安装软件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45756791/

相关文章:

powershell - 调用powershell函数的批处理脚本

powershell - Azure 自动化中的 ADAL : Type not loading intermittantly

xml - 从 PowerShell 保存格式正确的 XML

带有 ComputerName 的 powershell Get-Process 缺少路径

windows - 如何使用批处理获取前景窗口?

powershell - 在新线程powershell中调用函数

powershell - 使用 PowerShell 删除超过 15 天的文件

regex - 如何仅在 powershell 的子字符串中替换特定字符

powershell - 使用 PowerShell 确定 Bitlocker 版本

linux - windows 上的远程 powershell 脚本不通过 linux 中的 python 脚本运行