如何使用 powershell 运行安装程序? [英] How can I use powershell to run through an installer?

查看:37
本文介绍了如何使用 powershell 运行安装程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试安装一个软件,手动完成后,您可以在整个过程中选择配置选项.我正在尝试找出一种使用 powershell 自动执行此操作的方法,但我不知道如何设置这些配置选项.我相信我需要在安装程序 .exe 上运行 start-process 命令,但我不知道从哪里开始.我可以使用start-process命令上的参数传入我想要的配置吗?

解决方案

UPDATE:底部的几个链接包含有关如何处理安装setup.exe 文件的强>、配置文件提取.>

更新:请参阅Windows Installer PowerShell 模块 在 github.com(向下滚动描述,使用发布标签下载).我还没有真正测试过它,但它来自 Heath Stewart - Microsoft 高级软件工程师(github).

<小时>

我快速查找了该安装程序,但没有轻松找到.基本上,安装程序是 Windows 安装程序数据库 (MSI) 或其他东西 - 通常是某种setup.exe.MSI 数据库也可以包含在 setup.exe 中.

您应该知道,对于旧式安装程序,大规模部署的常见做法是使用 应用程序重新打包工具,然后编译用于安装的 MSI 文件(有效地将安装程序从旧格式转换为现代格式)MSI 格式).这是一项专业任务,需要对 Windows 和设置有很好的了解.它通常在大型公司中完成,用于非常大的软件分发.如果您在一家大公司工作,可能会有一个团队专门负责像您提到的那样打包软件.也许请咨询您的管理层.如果设置是 MSI,同一团队也可以根据您的规格为您修改.

<小时>

关于您的安装程序 EXE.尝试从命令行运行 setup.exe/a 并查看是否有将文件提取到网络安装点"(管理安装)的选项.然后您正在处理包装在 setup.exe 中的 MSI 文件.如果这不起作用,您也可以尝试 setup.exe/xsetup.exe/extract.

Windows Installer 具有内置功能,允许您通过在命令行中设置或通过转换应用的PUBLIC 属性(大写)自定义安装(Windows Installer 对供应商文件进行实质性更改的机制 - 它是在运行时从供应商处应用于安装数据库的部分数据库).

非 MSI 的传统安装程序技术通常很少有可靠的方法来自定义安装设置,而且它们在那里时往往是临时的.特别是静默运行和卸载可能是缺失或执行不佳的功能.这些安装通常都封装在 EXE 格式中,并且有许多用于生成它们的工具 - 每个都有自己的怪癖和功能.

换句话说,这完全取决于安装程序的实现方式.试一试 setup.exe/a,用新信息为我们更新您的答案(不要添加太多评论 - 我们会回来查看).

<小时>

关于使用 PowerShell.老实说,到目前为止,我还没有使用 PowerShell 进行部署.以下是如何使用 PowerShell 进行安装的基本说明:https://kevinmarquette.github.io/2016-10-21-powershell-installing-msi-files/

您还可以从 PowerShell 调用 MSI 文件的自动化,我认为这与您的要求无关,但这里有一个用于修改转换文件的快速链接:http://www.itninja.com/question/ps-how-to-edit-a-mst-文件.

安装 MSI 文件的正常方法是通过 Window 的内置 msiexec.exe 命令行.安装软件的基本msiexec.exe命令行是:

msiexec.exe/I "C:Your.msi"/QN/L*V "C:msilog.log" TRANSFORMS="C:1031.mst;C:My.mst"

快速参数说明:

/I = 运行安装序列/QN = 完全静默运行/L*V "C:msilog.log" = 详细日志记录TRANSFORMS="C:1031.mst;C:My.mst" = 应用转换 1031.mst 和 My.mst(见下文).

什么是转换?在这里解释:如何更好地利用 MSI 文件.

高级安装程序上有一个常规页面msiexec.exe 命令行.这是微软的MSDN 上的 msiexec.exe 文档.

<小时>

一些链接:

I am trying to install a piece of software that when done manually has configuration options you can choose from when going through the process. I am trying to figure out a way to automate this using powershell but am stuck as to how I can set those configuration options. I believe I would need to run the start-process command on the installer .exe but I don't know where to go from there. Can I use the parameters on the start-process command to pass in the configurations I want?

解决方案

UPDATE: Several links towards the bottom with information on how to handle installation, configuration and file extraction for setup.exe files.

UPDATE: See Windows Installer PowerShell Module on github.com (scroll down for description, use releases tab for download). I haven't really tested it much, but it is from Heath Stewart - Microsoft Senior Software Engineer (github).


I had a quick look for that installer, but didn't find it easily. Essentially the installer is either a Windows Installer database (MSI) or something else - generally a setup.exe of some kind. An MSI database can also be wrapped in a setup.exe.

You should be aware that for legacy style installers a common practice for large scale deployment is to capture the legacy install with an application repackager tool, and then compile an MSI file to use for installation (effectively converting an installer from an old format to modern MSI format). This is a specialist task requiring good understanding of Windows and setups. It is generally done in large corporations for very large software distributions. If you are in a large company there might be a team dedicated to packaging software like the one you mention. Maybe check with your management. If the setup is an MSI the same team can also modify that for you according to your specifications.


With regards to your installer EXE. Try to run setup.exe /a from the command line and see if you get an option to extract files to a "network install point" (administrative install). Then you are dealing with an MSI file wrapped in a setup.exe. If that doesn't work you can try setup.exe /x or setup.exe /extract as well.

Windows Installer has built-in features to allow you to customize the install via PUBLIC properties (uppercase) set at the command line or applied via a transform (Windows Installer's mechanism to apply substantial changes to the vendor file - it is a partial database that gets applied to the installation database from the vendor at runtime).

Non-MSI, legacy installer technologies generally have fewer reliable ways to customize the installation settings, and they tend to be rather ad hoc when they are there. In particular the silent running and uninstall may be features that are missing or poorly executed. These installs are generally all wrapped in EXE format, and there are many tools used to generate them - each with their own quirks and features.

In other words, it all depends on what the installer is implemented as. Give that setup.exe /a a go, and update your answer with new information for us (don't add too many comments - we will check back).


With regards to using PowerShell. I haven't used PowerShell for deployment so far to be perfectly honest. Here is a basic description of how to install using PowerShell: https://kevinmarquette.github.io/2016-10-21-powershell-installing-msi-files/

You can also invoke automation for MSI files from PowerShell, I don't think this is relevant for what you asked, but here is a quick link for modifying a transform file: http://www.itninja.com/question/ps-how-to-edit-a-mst-file.

The normal way to install MSI files is via Window's built-in msiexec.exe command line. The basic msiexec.exe command line to install software is:

msiexec.exe /I "C:Your.msi" /QN /L*V "C:msilog.log" TRANSFORMS="C:1031.mst;C:My.mst"

Quick Parameter Explanation:

/I = run install sequence
/QN = run completely silently
/L*V "C:msilog.log" = verbose logging
TRANSFORMS="C:1031.mst;C:My.mst" = Apply transforms 1031.mst and My.mst (see below).

What is a transform? Explained here: How to make better use of MSI files.

Advanced Installer has a general page on msiexec.exe command lines. And here is Microsoft's msiexec.exe documentation on MSDN.


Some links:

  • Perhaps see Michael Urman's answer here: Programmatically extract contents of InstallShield setup.exe. This is for Installshield packaged EXE files only.
  • Installshield setup.exe commands (general reference with some sample command lines - towards the end of the document it looks like the command lines are not correct, but the first ones look ok. The later ones are pretty obscure anyway - just thought I'd let you know since I link to it). Here is the official Installshield help documentation.
  • Wise setup.exe commands - Wise is no longer available, but if the setup is older it can still be packaged with Wise.
  • Advanced Installer standard command line. For this tool setups can apparently be extracted with setup.exe /x or setup.exe /extract. See the link for full list.
  • There was also a "silent switch finder" tool used to find hidden switches in exe files (for deployment), but it failed a virustotal.com scan so I won't link to it. Maybe it is using something exotic, such as scanning a file's header at a bit level or something weird that is flagged as malware by mistake? Either way, not a tool I would use.
  • And finally: http://unattended.sourceforge.net/installers.php. This link isn't bad, it presents some of the tools above and a few others - and the most common switches used. Untested by me, but looks ok.
  • And there are other deployment tools that have their own way of packaging and delivering EXE files - it can be a jungle. I can provide a list of such tools with more links, but maybe that's just confusing. Please try what is provided above first.
  • Here is a generic answer that might be helpful as well: Extract MSI from EXE

这篇关于如何使用 powershell 运行安装程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆