简体   繁体   English

如何使用调整后的设置在 /silent 模式下运行安装

[英]How to run an installation in /silent mode with adjusted settings

My goal: I want to create a CMD command that will installs a program with adjusted install settings.我的目标:我想创建一个 CMD 命令,它将安装一个具有调整安装设置的程序。

If I execute my .exe install file without any parameters, I have to click myself through the installation but I am able to change the install settings, like in which folder the setup will install the program or change the status of a checkbox.如果我在没有任何参数的情况下执行我的.exe安装文件,我必须在安装过程中单击自己,但我可以更改安装设置,例如安装程序将在哪个文件夹中安装程序或更改复选框的状态。

However, I want to run the installation in /silent mode, in which I don't know how to change the install settings.但是,我想在 /silent 模式下运行安装,在这种模式下我不知道如何更改安装设置。

So the question is:所以问题是:

Is there anyway to give the shell a correct installation settings and then execute the file in silent mode?反正有没有给shell一个正确的安装设置,然后在静默模式下执行文件?

I need this because I have to run the installation on multiple computers so it would be very comfortable if I had a script that runs the installation with correct settings.我需要这个,因为我必须在多台计算机上运行安装,所以如果我有一个使用正确设置运行安装的脚本会非常舒服。

Someone please guide.有人请指导。

Community : I'll elaborate later, but first let us do the easiest way.社区:我稍后会详细说明,但首先让我们做最简单的方法。 You could try to search for your software on sites dedicated to setup information and how to deploy various third party software silently: https://www.itninja.com/software您可以尝试在专门提供设置信息以及如何静默部署各种第三方软件的站点上搜索您的软件: https : //www.itninja.com/software

Similar, terser answer: Silent run installer (.exe) with parameters on Windows类似的,更简洁的答案: Windows 上带有参数的静默运行安装程序 (.exe)


1) Standard Packaging Formats : If the setup.exe wraps a standard packaging format such as an MSI file, then you generally need to find a way to extract the package inside and customize its silent installation using standardized customization mechanisms involving command lines and MSI transforms. 1) 标准打包格式:如果setup.exe打包了一个标准的打包格式,比如MSI文件,那么你通常需要找到一种方法来提取里面的包并使用涉及命令行和 MSI 转换的standardized customization mechanisms来定制它的静默安装.

2) Proprietary Packaging Formats : If the setup.exe is a proprietary format you need to either repackage it in a standard format (MSI) using tools to do so, or you need to run the installer in silent mode . 2) 专有打包格式:如果setup.exe是专有格式,您需要使用工具将其repackage为标准格式 (MSI),或者您需要以silent mode运行安装程序。 The latter can be unreliable, but is often done for small scale distribution.后者可能不可靠,但通常用于小规模分发。

Look and Feel : Experience can teach you what tool was used to make the setup.exe by looking at the dialogs at runtime.外观和感觉:通过查看运行时的对话框,经验可以告诉您使用什么工具来制作 setup.exe。 Sometimes you see a company name or a tool name embedded in them.有时您会看到公司名称或工具名称嵌入其中。


So in summary:所以总结一下:

  1. Extract standard package if possible.如果可能,提取标准包。
  2. Customize standard package.定制标准包。
  3. Repackage.重新包装。
  4. Install silently using original setup.exe.使用原始 setup.exe 静默安装。

Let's briefly describe these different tasks:让我们简要描述这些不同的任务:


Extraction of Files :文件提取

There is a forest of tools that can create setup.exe files, it is impossible to cover all of them.有很多工具可以创建setup.exe文件,不可能涵盖所有这些。 They might feature all kinds of different command line switches.它们可能具有各种不同的命令行开关。 A setup.exe can even be totally proprietary, meaning no deployment tool was used to make it at all. setup.exe甚至可以是完全专有的,这意味着根本没有使用部署工具来制作它。 It might have been compiled using Visual Studio for example.例如,它可能是使用 Visual Studio 编译的。

A description of tools that can be used (non-MSI , MSI , admin-tools , multi-platform , etc...). 可以使用的工具的描述non-MSIMSIadmin-toolsmulti-platform等...)。

Common tools such as Inno Setup seem to make extraction hard ( unofficial unpacker , not tried by me, run by virustotal ). Inno Setup等常用工具似乎使提取变得困难(非官方解包器,我没有尝试过,由virustotal运行)。 Whereas NSIS seems to use regular archives that standard archive software such as 7-Zip can open.NSIS似乎使用标准存档软件(如 7-Zip)可以打开的常规存档。

I try the following command lines to see if I can do a file extract:我尝试使用以下命令行来查看是否可以进行文件提取:

  • setup.exe /a (Installshield MSI) setup.exe /a (Installshield MSI)
  • setup.exe /stage_only (Installshield Suite) setup.exe /stage_only (Installshield Suite)
  • setup.exe /x (Wise, Advanced Installer) setup.exe /x (Wise, Advanced Installer)
  • setup.exe /extract_all (Installshield Installscript) setup.exe /extract_all (Installshield Installscript)
  • dark.exe -x outputfolder Setup.exe (WiX Burn Bundles - requires WiX toolkit installed ) dark.exe -x outputfolder Setup.exe (WiX Burn Bundles -需要安装 WiX 工具包

Additionally some general tricks exist:此外,还存在一些通用技巧

  1. Launch the setup.exe and look in the system's temp folder for extracted files.启动 setup.exe并在系统的临时文件夹中查找提取的文件。
  2. Another trick is to use 7-Zip , WinRAR , WinZip or similar archive tools to see if they can read the setup.exe format.另一个技巧是使用7-ZipWinRARWinZip或类似的存档工具来查看它们是否可以读取 setup.exe 格式。
  3. Some claim success by opening the setup.exe in Visual Studio .有些人通过在 Visual Studio 中打开 setup.exe声称成功。 Not a technique I use.不是我使用的技术。
  4. The general approach for finding switches is to open a command prompt and go setup.exe /?查找开关的一般方法是打开命令提示符并转到setup.exe /? or setup.exe /help or similar.setup.exe /help或类似的。
  5. Also check for vendor online information and sites such as https://www.itninja.com/software .还要检查供应商在线信息和站点,例如https://www.itninja.com/software

A sprawling answer on this topic: Extract MSI from EXE .关于此主题的庞大答案: 从 EXE 中提取 MSI

If you manage to extract (or the file format is viewable as an archive), you can look for PDF , HTML , TXT or CHM files with further deployment info.如果您设法提取(或文件格式可作为存档查看),您可以查找带有进一步部署信息的PDFHTMLTXTCHM文件。 Samples: ReadMe.txt , LSD.pdf , Large Scale Deployment.pdf , User Guide.chm , Manual.chm etc...示例: ReadMe.txtLSD.pdfLarge Scale Deployment.pdfUser Guide.chmManual.chm等...


MSI - Customize Standard Package: MSI - 定制标准套餐:

So, if the extract works and you extract an MSI file, then you can customize its installation in detail using standardized mechanisms.因此,如果提取有效并且您提取了MSI文件,那么您可以使用标准化机制详细自定义其安装。 Make sure to look for the files with deployment information mentioned above - PDFs , CHMs , TXTs , etc... They could feature sample command lines for you to use more or less directly.请一定要认准上面提到的部署信息的文件- PDFsCHMsTXTsetc...他们可以拥有示例命令行让你或多或少直接使用。

And crucially you could have extracted runtimes and prerequisites that also need to be deployed ( .NET framework , Crystal Reports , Visual C++ Runtime , etc... ).至关重要的是,您可以提取也需要部署的运行时和先决条件( .NET frameworkCrystal ReportsVisual C++ Runtime etc... )。 These are all managed and controlled on corporate networks and are not to be deployed with your package, but by their standardized packages.这些都是在企业网络上管理和控制的,不会与您的软件包一起部署,而是通过它们的标准化软件包进行部署。

Standardized customization mechanisms are great for corporate deployment, but require some MSI knowledge:标准化的定制机制非常适合企业部署,但需要一些 MSI 知识:

  • How to make better use of MSI files - a comprehensive description of MSI installation customization: with some sample command lines and description of the process. 如何更好地利用 MSI 文件- MSI 安装定制的全面描述:带有一些示例命令行和过程描述。

  • A simplified view of MSI installation customization . MSI 安装自定义的简化视图

    • Here you can see that some setup.exe files can be installed directly in silent mode by passing in a command line using the /v parameter.在这里你可以看到一些 setup.exe 文件可以通过使用/v参数传入命令行直接在静默模式下安装。 These are Installshield MSI setups.这些是 Installshield MSI 设置。

    • You can also see how the features in the MSI can be set at the command line.您还可以查看如何在命令行中设置 MSI 中的功能。

A couple of concrete samples (extracted from links above):几个具体示例(从上面的链接中提取):

  1. Command Line Customization命令行自定义

     msiexec.exe /i myinstaller.msi ADDLOCAL="Program,Dictionaries" SERIALKEY="1234-1234" /qn

    ADDLOCAL specifies what features from the MSI to install ( see feature sample screenshot here ). ADDLOCAL指定要安装MSI哪些功能(请参阅此处的功能示例屏幕截图)。 The uppercase values such as SERIALKEY are PUBLIC properties that can be set on the command line. SERIALKEY等大写值是可以在命令行上设置的 PUBLIC 属性。 These vary from setup to setup.这些因设置而异。 Look for documentation from vendor, check the Property table and check the setup dialogs.从供应商处查找文档,检查属性表并检查设置对话框。

  2. Transform转变

     msiexec.exe /i myinstaller.msi TRANSFORMS="mytransform.mst" /qn

    The transform approach sets all the values needed inside a little file that is applied at installation time.转换方法在安装时应用的小文件中设置所有需要的值。 It is called the transform.它被称为变换。 It is a little database fragment which is merged with the original MSI database at runtime.它是一个小的数据库片段,在运行时与原始 MSI 数据库合并。


Repackaging :重新包装

One way to create an MSI package from older-style, legacy setup.exe installers, is to "capture" the changes done to the system by using an Application Repackaging Tool which monitors changes made to the system whilst a setup.exe is being run.从旧式的旧 setup.exe 安装程序创建 MSI 包的一种方法是使用应用程序重新打包工具“捕获”对系统所做的更改,该工具在 setup.exe 运行时监视对系统所做的更改.

This task may look easy, but it isn't.这项任务可能看起来很容易,但事实并非如此。 In fact it is very hard to clean up the resulting captures so you don't create "loose cannon" MSI files that cause problems on desktops throughout your organization.事实上,清理生成的捕获非常困难,因此您不会创建“松散的大炮”MSI 文件,这些文件会导致整个组织的桌面出现问题。 Corporations have dedicated teams to do this job and excellent MSI files can result that cause no problems when installed silently.公司有专门的团队来完成这项工作,并且可以产生出色的 MSI 文件,在静默安装时不会导致任何问题。

This task is not for the causal user in my opinion.在我看来,这项任务不适合因果用户。 It requires investment in the technology, expertise and time.它需要对技术、专业知识和时间进行投资。 Besides the tools available are pricey.除了可用的工具是昂贵的。


Silent Installation :静默安装

Most setup.exe files will at least attempt to install silently, though there are no guarantees.大多数 setup.exe 文件至少会尝试静默安装,但不能保证。 It is entirely possible that the setup.exe is impossible to install silently. setup.exe 完全有可能无法静默安装。 I have seen it many times.我已经看过很多次了。 In these cases repackaging is necessary, but even repackaging can fail at times.在这些情况下,重新打包是必要的,但即使重新打包有时也会失败。 This is when it is time to push back on the vendor and ask them to get a grip about deployment.现在是时候回击供应商并要求他们掌握部署。 In a corporate world the software should be kicked head-first out of the application estate - if things work as they should.在企业界,软件应该首先被踢出应用程序资产 - 如果事情按预期进行。

Here is an old site dealing with the overall issue of silent installation of various setup.exe files: http://unattended.sourceforge.net/installers.php .这是一个处理各种 setup.exe 文件静默安装整体问题的旧站点: http : //unattended.sourceforge.net/installers.php

Here is a piece on silent uninstall which also describes silent running in general: Uninstall and Install App on my Computer silently这是关于静默卸载的一篇文章,它也描述了一般的静默运行: 在我的电脑上静默卸载和安装应用程序

The general approach for finding such switches is to go setup.exe /?查找此类开关的一般方法是转到setup.exe /? like you did.像你一样。 Often you can get a setup to install silently by trying something like this:通常,您可以通过尝试以下操作来获得静默安装的设置:


Some Links :一些链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM