AgentSkillsCN

Winget Silent Install

Winget 默默安装

SKILL.md

winget-silent-install

Non-interactive winget installation pattern.

Pattern

powershell
winget.exe install --id "{PACKAGE_ID}" --exact --source {SOURCE} --accept-source-agreements --disable-interactivity --silent --accept-package-agreements --force

Exact Matching

The --exact flag ensures only exact package ID matches are considered. Prevents ambiguous matches when package ID is substring of other packages.

Sources

Two primary sources:

  • winget — Default winget community repository
  • msstore — Microsoft Store packages

Specify with --source flag: --source winget or --source msstore

Flags

FlagPurpose
--idPackage identifier to install
--exactMatch package ID exactly (no partial matches)
--sourceSpecify package source (winget or msstore)
--accept-source-agreementsAuto-accept source license agreements
--disable-interactivityDisable all interactive prompts
--silentMinimal console output
--accept-package-agreementsAuto-accept package license agreements
--forceReinstall if already installed

Force Flag

Using --force ensures consistent state by reinstalling even if package exists. Useful for automation scripts where you want guaranteed fresh installation.

Examples

powershell
# From winget (default source)
winget.exe install --id "Microsoft.PowerShell" --exact --source winget --accept-source-agreements --disable-interactivity --silent --accept-package-agreements --force

# From Microsoft Store
winget.exe install --id "XPFFTQ032PTPHF" --exact --source msstore --accept-source-agreements --disable-interactivity --silent --accept-package-agreements --force

Usage in Scripts

This pattern is used throughout the winsetup-skills repository for consistent, reliable package installations without user intervention.