gpt4 book ai didi

powershell - 是否可以仅使用程序和shimgen的setup.exe来使用C​​hocolatey创建静默安装程序?

转载 作者:行者123 更新时间:2023-12-03 01:28:22 30 4
gpt4 key购买 nike

尝试为程序创建静默安装程序时,我是否可以在tools文件夹中使用该程序的setup.exe并为其生成填充程序?如果是这样,那么将其安装到哪里?
例如,我删除了tools文件夹中的所有项目,并将setup.exe放在ARM RVDS 4.1中。当我执行choco pack时,它生成了一个垫片,但现在我不知道该怎么做,或者我做对了。

最佳答案

您不想为安装程序设置填充程序-您想从chocolateyInstall.ps1调用安装程序来安装程序。您将如何在chocolateyInstall.ps1中为安装exe执行此操作的示例:

$packageInstallArgs = @{
PackageName = 'package-name'
FileType = 'exe'
SilentArgs = '/q /someOtherArguments' # This line is going to be installer specific, and is just a sample here
File = 'C:\Path\to\installer' # can be a relative path too
ValidExitCodes = 0, 1638 # array of acceptable return codes for the installer
}

Install-ChocolateyInstallPackage @packageInstallArgs

If your setup.exe is embedded inside the package, you can reference the current package folder directory with the following environment variable: $env:chocolateyPackageFolder. This variable only exists in the context of a Chocolatey package install. See here for more information on Chocolatey environment variables.



有关上述代码的一些细节:
  • PackageName:这是软件包
  • 的名称(id)
  • FileType:这是“exe”还是“msi”?
  • SilentArgs:执行程序
  • 的静默安装所需的任何参数
  • 文件:安装程序文件
  • 的相对或绝对路径
  • ValidExitCodes:应将任何退出代码视为成功安装。我在样本中使用的那些表示成功(0)和需要重新启动(1638)。有关标准安装程序退出代码的更多信息,请参见this page。搜索以ERROR_SUCCESS开头的错误代码,以获取可能需要支持的成功代码。


  • 为了方便起见,您可以选择为未自动放置在PATH上的程序生成垫片,以防万一没有自动生成垫片。

    程序的安装位置取决于安装程序的默认位置,以及安装程序是否允许您覆盖它。

    请注意,虽然自动生成的填充将在卸载时自动删除,但在使用 Install-BinFile 创建的填充时,需要使用 Uninstall-BinFile中的 chocolateyUninstall.ps1 手动删除软件包。

    以下是有关垫片的更多信息:
  • https://chocolatey.org/docs/features-shim
  • https://chocolatey.org/courses/creating-chocolatey-packages/shims
  • 关于powershell - 是否可以仅使用程序和shimgen的setup.exe来使用C​​hocolatey创建静默安装程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60453522/

    30 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com