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

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

问题描述

我正在尝试安装一个软件,该软件在手动完成后具有配置选项,您可以在执行该过程时从中进行选择.我试图找出一种使用Powershell自动执行此操作的方法,但对于如何设置这些配置选项却一无所知.我相信我需要在安装程序.exe上运行start-process命令,但我不知道从那里去哪里.我可以使用start-process命令上的参数来传递所需的配置吗?

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?

推荐答案

更新:指向底部的一些链接,其中包含有关如何处理 安装 的信息setup.exe文件的strong>, 配置 文件提取 .

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

更新:请参见 Windows Installer PowerShell模块 (向下滚动以获取描述,请使用 releases标签下载).我还没有真正测试过,但是它来自 Heath Stewart -微软高级软件工程师( github ).

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).

我快速找到了该安装程序,但并不容易找到它. 基本上,安装程序是Windows Installer数据库(MSI)或其他-通常是某种 setup.exe . MSI数据库也可以包装在setup.exe中.

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.

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

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

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).

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

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.

换句话说,这完全取决于安装程序的实现方式.放手setup.exe /a,并为我们提供新信息来更新您的答案(不要添加过多评论-我们将进行核对).

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).

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

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/

您还可以从PowerShell调用MSI文件的自动化,我认为这与您的要求无关,但是这里有一个用于修改转换文件的快速链接:

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.

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

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"

快速参数说明:

/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).

什么是转换?在这里解释: 高级安装程序> msiexec.exe命令行 .这是 Microsoft的MSDN上的msiexec.exe文档 .

某些链接:

  • 也许在这里看到 Michael Urman's 的答案: Installshield setup.exe命令 (一般参考带有一些示例命令行-在文档末尾,看起来命令行似乎不正确,但是前几个命令行看起来还不错,反之,它们还是很模糊的-只是以为我会告诉你,因为我链接到了它).这是 官方的Installshield帮助文档
  • 明智的setup.exe命令 -Wise不再可用,但是如果设置较旧,则仍可以与Wise打包在一起.
  • 高级安装程序标准命令行 .对于此工具,显然可以使用setup.exe /xsetup.exe /extract提取设置.有关完整列表,请参见链接.
  • 还有一个"无声开关查找器"工具,用于在exe文件中查找隐藏的开关(用于部署),但是它无法通过virustotal.com扫描,因此我不会链接到它.也许它正在使用一些奇怪的东西,例如以某种级别扫描文件的头文件,或者将某些奇怪的东西误认为是恶意软件?无论哪种方式,都不是我会使用的工具.
  • 最后: http://unattended.sourceforge.net/installers.php .该链接还不错,它提供了上面的一些工具以及其他一些工具-以及最常用的开关.未经我测试,但看起来还可以.
  • 还有其他一些部署工具,它们都有自己的打包和传送EXE文件的方式-它可以是丛林.我可以提供带有更多链接的此类工具列表,但这也许只是令人困惑.请先尝试上面提供的内容.
  • 这是一个通用的答案,可能也有帮助:从EXE提取MSI
  • 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天全站免登陆