本文介绍了使用 msiexec,这些指向安装程序的不同方式有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的问题.我只找到了两种实际运行我的 msi 文件的方法,但它们都不起作用.

I've got a simple problem. I've only found two ways that will actually run my msi file, and neither of them will work.

密切注意我对'"的使用.

Pay close attention to my usage of ' and ".

简单地说,我想要一种方法来做到这一点:

Simply put, I want a way to do this:

$Basics = "$PSScriptRoot"
Start-Process msiexec.exe -Wait -ArgumentList "/i $Basics\Installer_.64 bit_.msi /passive /norestart"

但是给 -ArgumentList 的字符串是无效的,我不知道为什么.正如您在下面看到的,我已经做了很多尝试,试图做到这一点.
$Basics 目前只是 $PSScriptRoot 的副本,但我希望它有一个单独的变量,以防我将来更改它.
/passive/norestart 出于测试目的被删除.

However the string being given to -ArgumentList is invalid, and I'm not sure why. I've done a lot of attempts as you can see below, in trying to get this right.
$Basics is just a copy of $PSScriptRoot for now, but I want it has a separate variable in case if I change it in the future.
/passive /norestart is removed for testing purposes.

注意:这不是实际安装程序文件的名称.这只是为了包含我试图用它运行的一些安装程序的所有奇怪字符(.,_,), 有.基本上是最坏的情况.

Note: This is not the actual installer file's name. This is made just to contain all the weird characters (.,_,) that some of the installers I'm trying to run with this, have. Basically a worst case scenario.

另外,很抱歉,这需要大量阅读,我不确定如何更好地格式化它.如果您知道更好的方法,请继续编辑.

Also, sorry in advance that this is a lot to read, I'm not really sure how to format it better. Go ahead and edit if you know a better way.

不按顺序,按照尝试的方式组织.我的第一次尝试是 "/i '$Basics\Installer_.64 bit_.msi'"

Not in order, organized by what kind of attempt it was. My first attempt was "/i '$Basics\Installer_.64 bit_.msi'"

Start-Process msiexec.exe -Wait -ArgumentList "/i $Basics\Installer_.64 bit_.msi"

^ 结果:打开通用 Windows Installer 帮助窗口.

^ Result: Opens generic Windows Installer help window.

Start-Process msiexec.exe -Wait -ArgumentList "/i '$Basics\Installer_.64 bit_.msi'"

^ 结果:打开通用 Windows Installer 帮助窗口.

^ Result: Opens generic Windows Installer help window.

Start-Process msiexec.exe -Wait -ArgumentList '/i $Basics\Installer_.64 bit_.msi'

^ 结果:无法打开此安装包.请验证该包是否存在并且您可以访问它,或联系应用程序供应商以验证这是一个有效的 Windows Installer 包."

^ Result: "This installation package could not be opened. Verify that the package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer package."

Start-Process msiexec.exe -Wait -ArgumentList '/i "$Basics\Installer_.64 bit_.msi"'

^ 结果:无法打开此安装包.请验证该包是否存在并且您可以访问它,或联系应用程序供应商以验证这是一个有效的 Windows Installer 包."

^ Result: "This installation package could not be opened. Verify that the package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer package."

Start-Process msiexec.exe -Wait -ArgumentList "/i Installer_.64 bit_.msi"

^ 结果:有效;但是,这是不可接受的,因为我需要能够在目录中放置一个变量.

^ Result: Works; However, this isn't acceptable as I need to be able to put a variable in the directory.

Start-Process msiexec.exe -Wait -ArgumentList '/i "C:\Users\Administrator\Downloads\flashdrive\redist\Install (x86 Office)\Installer_.64 bit_.msi"'

^ 结果:有效;但是,这是不可接受的,因为我需要能够在目录中放置一个变量.

^ Result: Works; However, this isn't acceptable as I need to be able to put a variable in the directory.

Start-Process msiexec.exe -Wait -ArgumentList "/i C:\Users\Administrator\Downloads\flashdrive\redist\Install (x86 Office)\Installer_.64 bit_.msi"

^ 结果:打开通用 Windows Installer 帮助窗口.

^ Result: Opens generic Windows Installer help window.

Start-Process msiexec.exe -Wait -ArgumentList "/i .\Installer_.64 bit_.msi"

^ 结果:无法打开此安装包.请验证该包是否存在并且您可以访问它,或联系应用程序供应商以验证这是一个有效的 Windows Installer 包."

^ Result: "This installation package could not be opened. Verify that the package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer package."

推荐答案

重新引用:我看到有人写了很多关于 PowerShell 和转义序列的文章.看起来很复杂:在命令上设置公共属性值行 - 还有其他帖子.

替代方案?:也许您可以通过 MSI API COM 调用?我有关于卸载 MSI 软件包的各种方法的旧答案.我会看看我是否可以挖掘一个 PowerShell 示例,同时这里是一个使用 MSI API COM 调用 的 VBScript 版本:

Alternatives?: Perhaps you can go via MSI API COM calls? I have this old answer on various ways to uninstall MSI packages. I'll see if I can dig up a PowerShell example, in the meantime here is a VBScript version using MSI API COM calls:

Set installer = CreateObject("WindowsInstaller.Installer")
installer.InstallProduct "C:\Product.msi", "REBOOT=ReallySuppress"

还有 WMI - 我从未使用过.请参阅此处的第 10 节.

链接:

这篇关于使用 msiexec,这些指向安装程序的不同方式有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 01:11