Giter Site home page Giter Site logo

affinis-mcs / winget-install Goto Github PK

View Code? Open in Web Editor NEW

This project forked from asheroto/winget-install

0.0 0.0 0.0 266 KB

Install winget tool using PowerShell! Prerequisites automatically installed. Works on Windows 10/11 and Server 2022.

Home Page: https://bit.ly/winget-install

License: GNU General Public License v3.0

PowerShell 100.00%

winget-install's Introduction

winget Windows 10 GitHub Release Date - Published_At GitHub Downloads - All Releases GitHub Sponsor Ko-Fi Button

Install winget from PowerShell

winget, a command line package manager, doesn't have a command line installer? ๐Ÿคฃ Now it does! ๐Ÿ˜Š

Requirements

  • Requires PowerShell running with Administrator rights
  • Compatible with:
    • Windows 10 (Version 1809 or higher)
    • Windows 11
    • Server 2022
  • Not compatible with:
    • Server 2019 (winget not supported)

Features

  • Installs winget-cli directly from PowerShell
  • Always fetches the latest winget version
  • Automatically verifies OS compatibility
  • Determines and installs the appropriate prerequisites based on OS version
  • Updates existing prerequisites to their latest versions
  • Supports x86/x64 and arm/arm64 architectures
  • Allows bypassing of existing winget installation verification through $Force session variable or -Force parameter

Script Functionality

  • Identifies processor architecture to decide which prerequisites are needed (x86/x64 or arm/arm64)
  • Checks Windows OS version for compatibility (Windows 10, Windows 11, Server 2022)
  • Verifies Windows 10 release ID for compatibility (must be 1809 or newer)
  • Manages prerequisite versions based on OS:
    • Forces older versions on Windows 10 and Server 2022
    • Uses latest versions from Microsoft Store on Windows 11
  • Executes winget registration command on Windows 10
  • VCLibs is installed straight from the appx package
    • Primary method
      • If Windows 10 or Server 2022, alternate method is forced so that older version of prerequisite is used (newer version is not compatible)
      • Determines the direct download URL for the appx package
      • Installs appx package using direct download URL
    • Alternate method (if primary download URL fails)
      • Uses version 14.00 for compatibility reasons
      • Installs appx package using aka.ms URL
  • UI.Xaml is installed
    • Primary method
      • If Windows 10 or Server 2022, alternate method is forced so that older version of prerequisite is used (newer version is not compatible)
      • Determines the direct download URL for the appx package
      • Installs appx package using direct download URL
    • Alternate method (if primary download URL fails)
      • Uses version 2.7.3 for compatibility reasons
      • Downloads nupkg package using nuget.org URL
      • Extracts appx package from nupkg package
      • Installs appx package using extracted appx package
  • winget-cli is then installed using the latest version from GitHub
  • Machine & User PATH variables are adjusted to include WindowsApps folder if needed

Setup

Note: For a stable experience, use one of the methods listed below (#1, #2, or #3) to fetch the latest version. Using the version directly from the GitHub repository is not advised, as it could be under active development and not fully stable.

Method 1 - PowerShell Gallery

Open PowerShell as Administrator and type

Install-Script winget-install -Force

Follow the prompts to complete the installation (you can tap A to accept all prompts or Y to select them individually.

Note: -Force is optional but recommended, as it will force the script to update if it is outdated. If you do not use -Force, it will not overwrite the script if outdated.

Usage

winget-install

The script is published on PowerShell Gallery under winget-install.

Tip - How to trust PSGallery

If you want to trust PSGallery so you aren't prompted each time you run this command, or if you're scripting this and want to ensure the script isn't interrupted the first time it runs...

Install-PackageProvider -Name "NuGet" -Force
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted

Method 2 - One Line Command (Runs Immediately)

The URL asheroto.com/winget always redirects to the latest code-signed release of the script.

irm asheroto.com/winget | iex

If PowerShell closes right away, it's likely because winget is already on your system. To override this and run the script again, set the $Force session variable to $true prior to executing the command. Note that the -Force parameter won't work in this context; it's only effective when the script is called using winget-install. If you're using the one-line command, you'll need to use the $Force session variable instead.

$Force = $true
irm asheroto.com/winget | iex

Method 3 - Download Locally and Run

Parameters

No parameters are required to run the script, but there are some optional parameters to use if needed.

Parameter Required Description
-DebugMode No Enables debug mode, which shows additional information for debugging.
-DisableCleanup No Disables cleanup of the script and prerequisites after installation.
-Force No Ensures installation of winget and its dependencies, even if already present.
-CheckForUpdate No Checks if there is an update available for the script.
-UpdateSelf No Updates the script to the latest version.
-Version No Displays the version of the script.
-Help No Displays the full help information for the script.

Troubleshooting

  • Before releasing a new version, the script is tested on a clean install of Windows 10 22H2, Server 2022 21H2, and Windows 11 22H2
  • If you run into an issue, please ensure your system is compatible & fully updated
  • Try running winget-install again, sometimes the script will fail due to a temporary issue with the prerequisite server URLs
  • Try using the -DebugMode and -DisableCleanup parameters to see if it provides any additional information
  • Try installing winget manually to see if the issue exists with winget itself
  • If the issue occurs when installing winget manually, please open an issue on the winget-cli repo (unrelated to this script)
  • Check the winget-cli Troubleshooting Guide
  • If the problem only occurs when using this script, please open an issue here

Contributing

If you're like to help develop this project: fork the repo. ๐Ÿ˜Š

winget-install's People

Contributors

asheroto avatar thomasschadenhofer avatar misterzeus avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.