如何通过Bolt任务在Windows机器上安装Notepad++?求对应命令示例
No, the default package Bolt task won't work directly for installing Notepad++ on Windows—this task is built for Unix-like package managers (APT, YUM, etc.). But you have several straightforward alternatives using Windows-native tools or dedicated Bolt tasks to get Notepad++ installed.
Option 1: Use Chocolatey via Bolt's Official Module
Chocolatey is a widely used Windows package manager, and there’s an official Puppet module that adds Bolt tasks for managing packages with it:
- First, install the Chocolatey module on your Bolt control machine:
bolt module install puppetlabs-chocolatey - If Chocolatey isn’t already set up on your target Windows machine, you can install it with a Bolt task:
bolt task run chocolatey::install --targets your-windows-host - Then install Notepad++ (note Chocolatey uses
notepadplusplusas the package name, notnotepad++):bolt task run chocolatey::install package=notepadplusplus --targets your-windows-host
Option 2: Use WinGet (Built-in Windows Package Manager)
WinGet comes pre-installed on modern Windows 10/11 systems, so you can run it directly via a Bolt command without extra modules:
bolt command run "winget install --id Notepad++.Notepad++ --silent" --targets your-windows-host
The --silent flag ensures the installation runs in the background without user prompts. If your target machine has an older WinGet version, you might need to add the -e flag to accept license agreements automatically.
Option 3: Create a Custom Bolt Task (For Reusability)
If you need to install Notepad++ regularly, wrap the installation command into a custom Bolt task for cleaner, repeatable runs:
- Set up this directory structure on your Bolt control machine:
tasks/ ├── install_notepadpp.json └── install_notepadpp.ps1 - Add metadata to
install_notepadpp.json:{ "description": "Installs Notepad++ on Windows using WinGet", "supports_noop": false, "parameters": {} } - Add the installation logic to
install_notepadpp.ps1:winget install --id Notepad++.Notepad++ --silent --accept-source-agreements - Run your custom task with:
bolt task run install_notepadpp --targets your-windows-host
内容的提问来源于stack exchange,提问作者S.Chandra Sekhar

