winget の自動化
#Windows #winget #wip
WinGet はデフォルトでサイレントインストールを実行するが、インストール時に様々なオプションを選択できるソフトも少なくない
サイレントインストールでもインストールオプションを変更できれば新規PCセットアップが楽になる
今回はサイレントインストール時にオプションを変更する方法を調べる
WinGet のインストールオプション
インストールコマンドに --custom フラグか --override フラグをつけると、インストーラーに渡す引数を追加・上書きできる
インストールオプションを調べる
まず Installer タイプを調べる
code:Powershell.shell
PS > winget show Microsoft.VisualStudioCode
見つかりました Microsoft Visual Studio Code Microsoft.VisualStudioCode
バージョン: 1.100.3
公開元: Microsoft Corporation
発行元 URL: https://www.microsoft.com/
モニカー: vscode
説明: Microsoft Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. Microsoft Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows.
ホーム ページ: https://code.visualstudio.com
ライセンス: Microsoft Software License
ライセンス URL: https://code.visualstudio.com/license
プライバシー URL: https://privacy.microsoft.com/
タグ:
developer-tools
editor
インストーラー:
インストーラーの種類: inno
インストーラーの URL: https://vscode.download.prss.microsoft.com/dbazure/download/stable/258e40fedc6cb8edf399a463ce3a9d32e7e1f6f3/VSCodeUserSetup-x64-1.100.3.exe
インストーラーの SHA256: a7e37b9cf6d47beb4c564d167022ca324bfeb971944f21a9ce87e953e154a52b
オフライン配信をサポート: true
inno setup の場合
以下ページを参考に、セットアップ時のオプションを設定として吐き出す
Inno Setup Help
code:powershell.shell
PS > winget install -i --installer-type inno -e --id Microsoft.VisualStudioCode --custom "/SAVEINF=installer-config.inf"
code:powershell.shell
見つかりました Microsoft Visual Studio Code Microsoft.VisualStudioCode バージョン 1.100.3
このアプリケーションは所有者からライセンス供与されます。
Microsoft はサードパーティのパッケージに対して責任を負わず、ライセンスも付与しません。
インストーラーハッシュが正常に検証されました
パッケージのインストールを開始しています...
インストールが完了しました
設定を確認
code:powershell.shell
PS > cat installer-config.inf
Setup
Lang=japanese
Dir=C:\Users\onotakahiro\AppData\Local\Programs\Microsoft VS Code
Group=Visual Studio Code
NoIcons=0
Tasks=addcontextmenufiles,addcontextmenufolders,associatewithfiles,addtopath
設定の内容をそのまま引数として指定するか、設定ファイルとして渡してやる
code:winget-command-sample_1.shell
winget install --installer-type inno -e --id Microsoft.VisualStudioCode --custom "/NoIcons=0 /Tasks=addcontextmenufiles,addcontextmenufolders,associatewithfiles,addtopath"
code:winget-command-sample_1.shell
winget install --installer-type inno -e --id Microsoft.VisualStudioCode --custom "/LOADINF=installer-config.inf"
NSIS (Nullsoft) の場合
共通のフラグがほぼないので、都度対応するしかない
Command Line Usage
3.2 Installer Usage
Generated installers and uninstallers accept a few options on the command line. These options give the user a bit more control over the installation process.
3.2.1 Common Options
/NCRC disables the CRC check, unless CRCCheck force was used in the script.
/S runs the installer or uninstaller silently. See section 4.12 for more information.
/D sets the default installation directory ($INSTDIR), overriding InstallDir and InstallDirRegKey. It must be the last parameter used in the command line and must not contain any quotes, even if the path contains spaces. Only absolute paths are supported.
3.2.2 Uninstaller Specific Options
_?= sets $INSTDIR. It also stops the uninstaller from copying itself to the temporary directory and running from there. It can be used along with ExecWait to wait for the uninstaller to finish. It must be the last parameter used in the command line and must not contain any quotes, even if the path contains spaces.
3.2.3 Examples
installer.exe /NCRC
installer.exe /S
installer.exe /D=C:\Program Files\NSIS
installer.exe /NCRC /S /D=C:\Program Files\NSIS
uninstaller.exe /S _?=C:\Program Files\NSIS
# uninstall old version
ExecWait '"$INSTDIR\uninstaller.exe" /S _?=$INSTDIR'
Delete "$INSTDIR\uninstaller.exe"
RMDir $INSTDIR
今回は Wireshark を例にみてく
code:powershell.shell
PS > winget show WiresharkFoundation.Wireshark
見つかりました Wireshark WiresharkFoundation.Wireshark
バージョン: 4.4.7
公開元: The Wireshark developer community, https://www.wireshark.org
発行元 URL: https://wiresharkfoundation.org/
発行元のサポート URL: https://gitlab.com/wireshark/wireshark/-/issues
作成者: The Wireshark Foundation
モニカー: wireshark
説明:
Wireshark is the world's foremost network protocol analyzer. It lets you see what's happening on your network at a microscopic level. It is the de facto (and often de jure) standard across many industries and educational institutions.
Wireshark development thrives thanks to the contributions of networking experts across the globe. It is the continuation of a project that started in 1998.
ホーム ページ: https://www.wireshark.org/
ライセンス: GPL-2.0
ライセンス URL: https://gitlab.com/wireshark/wireshark/-/blob/HEAD/COPYING
プライバシー URL: https://wiresharkfoundation.org/privacy-policy/
著作権: Copyright 1998-2025 Gerald Combs <gerald@wireshark.org> and contributors
リリース ノート:
Bug Fixes
The following vulnerabilities have been fixed:
- wnpa-sec-2025-02 Dissection engine crash. Issue 20509. CVE-2025-5601.
The following bugs have been fixed:
- Wireshark does not correctly decode LIN "go to sleep" in TECMP and CMP. Issue 20463.
- Dissector bug, Protocol CIGI. Issue 20496.
- Green power packets are not dissected when proto_version == ZBEE_VERSION_GREEN_POWER. Issue 20497.
- Packet diagrams misalign or drop bitfields. Issue 20507.
- Corruption when setting heuristic dissector table UI name from Lua. Issue 20523.
- LDAP dissector incorrectly displays filters with singleton "&" Issue 20527.
- WebSocket per-message compression extentions: fail to decompress server messages (from the 2nd) due to parameter handling. Issue 20531.
- The LL_PERIODIC_SYNC_WR_IND packet is not properly dissected (packet-btle.c) Issue 20554.
New and Updated Features
New Protocol Support
There are no new protocols in this release.
Updated Protocol Support
AT, BT LE LL, CIGI, genl, LDAP, LIN, Logcat Text, net_dm, netfilter, nvme, SSH, TCPCL, TLS, WebSocket, ZigBee, and ZigBee ZCL
New and Updated Capture File Support
There is no new or updated capture file support in this release.
Updated File Format Decoding Support
There is no updated file format support in this release.
リリース ノート URL: https://www.wireshark.org/update/relnotes/wireshark-4.4.7.html
Documentation:
Documentation: https://www.wireshark.org/docs/
Learn: https://www.wireshark.org/learn
FAQ: https://www.wireshark.org/faq.html
Wiki: https://wiki.wireshark.org/
タグ:
analyzer
capture
network
protocol
sniffer
traffic
インストーラー:
インストーラーの種類: nullsoft
インストーラーの URL: https://2.na.dl.wireshark.org/win64/all-versions/Wireshark-4.4.7-x64.exe
インストーラーの SHA256: 2e33fbda09cbc697a293faeba8a4fe4c2fcfc57db7ccf6421ec1f2c05223e6ac
リリース日: 2025-06-04
オフライン配信をサポート: true
方法1:ソフトの公式マニュアルをみる
2.3. Installing Wireshark under Windows
方法2:インストーラーのソースコードを読む
以下のフォームを参考にGetParameters・GetOptionsマクロを探す
NSIS コマンドラインパラメータ - NSIS フォーラム
Wiresharkだとコレ
wireshark/packaging/nsis/wireshark.nsi · wireshark/wireshark · GitHub
https://scrapbox.io/files/684cfdb92b4c2a33dc5c5eea.png
wix
msi ファイルの公開プロパティーを取得して、それを実行時に設定する
code:powershell.shell
PS > winget show Amazon.Corretto.24.JDK
見つかりました Amazon Corretto 24 Amazon.Corretto.24.JDK
バージョン: 24.0.1.9
公開元: Amazon
発行元 URL: https://aws.amazon.com/
発行元のサポート URL: https://github.com/corretto/corretto-24/issues
作成者: Amazon
説明: Amazon Corretto is a no-cost, multiplatform, production-ready distribution of the Open Java Development Kit (OpenJDK). Corretto comes with long-term support that includes performance enhancements and security fixes. Amazon runs Corretto internally on thousands of production services and Corretto is certified as compatible with the Java SE standard. With Corretto, you can develop and run Java applications on popular operating systems, including Linux, Windows, and macOS.
ホーム ページ: https://docs.aws.amazon.com/corretto/
ライセンス: GPL-2.0 with Classpath Exception
ライセンス URL: https://aws.amazon.com/corretto/faqs/#Licensing_and_Open_Source
プライバシー URL: https://aws.amazon.com/privacy/
著作権: Copyright © 2024
著作権 URL: https://github.com/corretto/corretto-24/blob/develop/TRADEMARKS.md
リリース ノート URL: https://github.com/corretto/corretto-24/blob/develop/CHANGELOG.md
タグ:
java
jdk
jre
jvm
インストーラー:
インストーラーの種類: wix
インストーラーの URL: https://corretto.aws/downloads/resources/24.0.1.9.1/amazon-corretto-24.0.1.9.1-windows-x64.msi
インストーラーの SHA256: 127db1652468a9270921da0ca027838ea0a654b80948ad6e902df3b22de53f2d
リリース日: 2025-04-15
オフライン配信をサポート: true
code:show-msi-prop.ps1
$msiFile = "C:\amazon-corretto-24.0.1.9.1-windows-x64.msi"
$installer = New-Object -ComObject WindowsInstaller.Installer
$database = $installer.OpenDatabase($msiFile, 0)
$view = $database.OpenView("SELECT * FROM Property")
$view.Execute()
$record = $view.Fetch()
while ($record) {
$name = $record.StringData(1)
$value = $record.StringData(2)
Write-Output "$name = $value"
$record = $view.Fetch()
}
code:show-msi-prop.ps1
PS > .\msi-prop.ps1
UpgradeCode = {3EEF11EA-DDFA-4BF4-A5ED-DDCA47D0628C}
WixUIRMOption = UseRM
ALLUSERS = 1
ProductNameForWelcome = Amazon Corretto (x64) - v24.0.1.9
WIXUI_INSTALLDIR = INSTALLDIR
Manufacturer = Amazon
ProductCode = {3884352C-1CB8-4C3C-9645-BDE59CDF4D9A}
ProductLanguage = 1033
ProductName = Amazon Corretto (x64)
ProductVersion = 24.0.1.9
DefaultUIFont = WixUI_Font_Normal
WixUI_Mode = FeatureTree
ErrorDialog = ErrorDlg
SecureCustomProperties = WIX_UPGRADE_DETECTED