确定 MSI/EXE 是否支持某些标志/参数?

发布于 2024-12-02 19:10:34 字数 377 浏览 2 评论 0原文

我正在创建一个可以运行 MSI 和 EXE 的自动更新程序。这些 MSI/EXE 不是我自己的。我想使用任何无人值守/静默安装选项(如果存在)。有没有某种方法可以确定 MSI/EXE 是否具有某种无人值守安装支持,如果是,则获取正确的参数,以便在运行时将其传递给文件?我知道,默认情况下“/quiet”是静默安装选项,但我也对 EXE 和任何可能自定义此选项的 MSI 感到好奇。

这个问题 - 检测用于无人值守安装的 msi 参数 - 类似,但链接答案已损坏,我无法从答案中弄清楚我会做什么。

谢谢。

I'm creating an auto-updater that can run MSIs and EXEs. These MSIs/EXEs aren't my own. I'd like to use any unattended/silent install option if it exists. Is there some way to determine if an MSI/EXE has some sort of unattended install support and, if so, get the right argument so I can pass it to the file when I run it? I know, by default '/quiet' is the silent install option, but I'm also curious about EXEs and any MSIs that maybe have customized this option.

This question - detect msi parameters for unattended install - is similar, but the links in the answer are broken and I can't figure out from the answer what I would do.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

秋叶绚丽 2024-12-09 19:10:34

只需在打开日志记录的情况下运行安装程序,它就会向您显示特定 MSI 接受的所有可能参数。

例如:
msiexec /log logfile.txt /i installer.msi

运行整个安装程序,logfile.txt 将向您显示可传递的参数“Property(S)”或“Property(C)”,其中包含名称全部大写。

来源:
http://www.codeproject .com/Articles/16767/如何将命令行参数传递到 MSI-Installe

Just run through the installer with logging turned on and it will show you all of the possible parameters that the specific MSI accepts.

For example:
msiexec /log logfile.txt /i installer.msi

Run through the entire installer and the logfile.txt will show you the passable parameters as "Property(S)" or "Property(C)" with the name in all caps.

Source:
http://www.codeproject.com/Articles/16767/How-to-Pass-Command-Line-Arguments-to-MSI-Installe

失退 2024-12-09 19:10:34

如果是MSI,那么参数是标准的,您可以使用msiexec /?获取选项列表或查看MSDN 上的文档

无法检测任意 EXE 所支持的选项(如果有)。尝试从供应商那里查找文档,或者尝试 /? 开关...

If it's MSI, then the parameters are standard, you can get the list of options with msiexec /? or view the docs on MSDN.

There's no way to detect options for an arbitrary EXE which options it supports, if any. Try to find docs from the vendor, or try /? switch…

梦里泪两行 2024-12-09 19:10:34

注意:我在检测上发布了此响应的变体无人值守安装的 msi 参数 你提到的问题。)

lessmsi,是一个很棒的如果您愿意使用 GUI 并进行一些手动调查,那么该工具肯定可以在这里使用。

您可以尝试以下命令:

lessmsi l -tProperty <msi_name>

...但是上面的命令不太可能包含您正在寻找的所有内容。

本质上保证您获得所有可能属性的一种方法是使用 MSI 文件实际执行安装、修复或卸载,并按照 乔恩·希斯的回答

如果您希望在日志文件中筛选更少的文本,则可以将日志设置设置为仅记录属性:

<msi_name> /lp! <msi_property_logfile>

或者

msiexec /lp! <msi_property_logfile> /i <msi_name>

我更喜欢通过“提取”绕过安装/删除/修复需要的方法。与 lessmsi 相比,此方法的优点是它不需要第 3 方实用程序(即 lessmsi),并且不需要您搞乱任何安装。您确实需要有足够的磁盘空间来实际安装该程序(为了安全起见,可能还需要一些额外的空间)。然后您可以执行以下操作:

msiexec /a <msi_name> /lp! <msi_property_logfile> TARGETDIR=<absolute_path_to_extract_to>

请注意, 可以指向不存在的目录(该命令将创建必要的目录,否则会失败)。

如果您出于某种原因讨厌安装 UI,则可以附加 /qr 选项,这将“减少”甚至可能消除 UI,而不会影响属性日志记录过程。但请注意——如果您的界面比简化的 UI 更“低”(即 /qb|/passive/qn|/quiet),您的 可能缺少某些属性。

以下命令可以有效地为某个目录中的每个 MSI 文件生成一个属性日志文件(使用 DIR /B 而不是 DIR /B/S 来不递归子目录;删除如果您想保留提取的文件,则使用 RD 命令):

cmd /C "FOR /F delims^=^| %G IN ('DIR /B/S "%DirToSearch%\*.msi"') DO msiexec /a "%G" /qr /lp! "%~nG_log.txt" TARGETDIR="%~dpnG_extract" && RD /S/Q "%~dpnG_extract""

如果您出于某种原因想在 PowerShell 中运行该命令,请使用以下命令:

cmd /C "FOR /F delims^=^| %G IN ('DIR /B/S ""%DirToSearch%\*.msi""') DO msiexec /a ""%G"" /qr /lp! ""%~nG_log.txt"" TARGETDIR=""%~dpnG_extract"" && RD /S/Q ""%~dpnG_extract"""

该过程完成后,您只需打开日志文件即可并注意以开头的行属性(S):/属性(C):正如 Jon Heese 提到的。

一般来说,可以为安装设置的参数/属性以全部大写形式记录;例如,可以设置ALLUSERS ALLUSERS=1,以便安装适用于所有用户。

(Note: I posted a variation of this response on the detect msi parameters for unattended install question you mentioned.)

There's lessmsi, is a great tool that certainly works here if you're willing to use a GUI and do some manual investigation.

You can try the following command:

lessmsi l -tProperty <msi_name>

...But it's unlikely that the above will have everything you're looking for.

One way to essentially guarantee that you get all the possible properties is to actually perform either an installation, repair, or uninstall with the MSI file and log the process as mentioned in Jon Heese's answer.

If you want less text to sift through in the log file, you can set the log setting to log only the properties:

<msi_name> /lp! <msi_property_logfile>

or

msiexec /lp! <msi_property_logfile> /i <msi_name>

I prefer a method that bypasses the need of install/remove/repair-ing through "extraction". The advantages this method has over lessmsi is that it doesn't require a 3rd-party utility (i.e. lessmsi), and it doesn't require you to mess with any installations. You do need to have enough disk space to actually install the program (and probably some additional space, to be safe). Then you can do something like:

msiexec /a <msi_name> /lp! <msi_property_logfile> TARGETDIR=<absolute_path_to_extract_to>

Note that the <absolute_path_to_extract_to> can point to a nonexistent directory (the command will create the directories necessary or fail).

If you hate the installation UI for whatever reason you can append the /qr option, which will 'reduce' and possibly eliminate the UI without impairing the property logging process. Be warned however--if you go "lower" than the reduced UI (viz. /qb|/passive or /qn|/quiet), your <msi_property_logfile> may be missing some properties.

The following command can effectively produce a Property log file for each MSI file in some directory (use DIR /B rather than DIR /B/S to not recurse subdirectories; remove the RD command if you want to keep the extracted files):

cmd /C "FOR /F delims^=^| %G IN ('DIR /B/S "%DirToSearch%\*.msi"') DO msiexec /a "%G" /qr /lp! "%~nG_log.txt" TARGETDIR="%~dpnG_extract" && RD /S/Q "%~dpnG_extract""

and if you want to run that in PowerShell for whatever reason, use the command below instead:

cmd /C "FOR /F delims^=^| %G IN ('DIR /B/S ""%DirToSearch%\*.msi""') DO msiexec /a ""%G"" /qr /lp! ""%~nG_log.txt"" TARGETDIR=""%~dpnG_extract"" && RD /S/Q ""%~dpnG_extract"""

Once the process has finished, you simply open up the logfile and note the lines beginning with Property(S):/Property(C):as Jon Heese mentioned.

Generally speaking, the parameters/properties that can be set for an install are logged in ALL CAPS; for example, ALLUSERS can be set ALLUSERS=1 so that the installation is for all users.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文