I need a script to SILENTLY install winget

Page 1 of 2 12 LastLast

  1. Posts : 46
    Windows 10 23H2
       #1

    I need a script to SILENTLY install winget


    I was trying to mount a script that installs winget, install apps that I need, then installs lastest Microsoft Updates and auto-reboot the machine when finishes. I got pretty far of my goal. I'm stuck on getting to install winget silently. I only could install winget from msstore, but they pop-up asking to click Yes to continue (therego, not silently). Can anyone help?

    I must mention that NONE of the code that I use is from me. I'm below newbie on script powershell. I only see community scripts and adapt to my need.

    Code:
    # Check if winget is installed
            Write-Host "Checking if Winget is Installed..."
            if (Test-Path ~\AppData\Local\Microsoft\WindowsApps\winget.exe) {
                #Checks if winget executable exists and if the Windows Version is 1809 or higher
                Write-Host "Winget Already Installed"
            }
            else {
                #Gets the computer's information
                $ComputerInfo = Get-ComputerInfo
    
                #Gets the Windows Edition
                $OSName = if ($ComputerInfo.OSName) {
                    $ComputerInfo.OSName
                }else {
                    $ComputerInfo.WindowsProductName
                }
    
                if (((($OSName.IndexOf("LTSC")) -ne -1) -or ($OSName.IndexOf("Server") -ne -1)) -and (($ComputerInfo.WindowsVersion) -ge "1809")) {
                    
                    Write-Host "Running Alternative Installer for LTSC/Server Editions"
    
                    # Switching to winget-install from PSGallery from asheroto
                    # Source: https://github.com/asheroto/winget-in...
                    
                    Start-Process powershell.exe -Verb RunAs -ArgumentList "-command irm https://raw.githubusercontent.com/ChrisTitusTech/winutil/$BranchToUse/winget.ps1 | iex | Out-Host" -WindowStyle Normal
                    
                }
                elseif (((Get-ComputerInfo).WindowsVersion) -lt "1809") {
                    #Checks if Windows Version is too old for winget
                    Write-Host "Winget is not supported on this version of Windows (Pre-1809)"
                }
                else {
                    #Installing Winget from the Microsoft Store
                    Write-Host "Winget not found, installing it now."
                    Start-Process "ms-appinstaller:?source=https://aka.ms/getwinget" 
                    $nid = (Get-Process AppInstaller).Id
                    Wait-Process -Id $nid
                    Write-Host "Winget Installed"
                }
    }
    That's the screen that shows asking me to click update in order the script to continue:
    Attached Thumbnails Attached Thumbnails I need a script to SILENTLY install winget-screenshot_1.png  
      My Computer


  2. Posts : 4,158
    Windows 11 Pro, 22H2
       #2

    I'm guessing that winget is asking you to accept the license agreement.

    I have not tried the below command myself, but I think that this should do the trick. This should install it silently and bypass the prompt to accept the license agreement.

    winget upgrade "App Installer" --silent --accept-source-agreements

    Let me know if this helps!
      My Computers


  3. Posts : 46
    Windows 10 23H2
    Thread Starter
       #3

    hsehestedt said:
    winget upgrade "App Installer" --silent --accept-source-agreements
    That command works for installing apps from winget. What I wanna know is how to install Winget itself silently, not the apps.

    The basic need of this script is to run a script on a complete default Windows installation and the script install winget to the latest version, install some apps that I need, than verify for updates from microsoft, installs all available updates, restart if needed, and that's it.

    I could find all the steps, except for installing winget itself silently. Always prompt a interface to click update and I need to do it silently.
      My Computer


  4. Posts : 4,808
    Windows 11 Pro 64 Bit 22H2
       #4
      My Computer


  5. Posts : 46
    Windows 10 23H2
    Thread Starter
       #5

    No, that's helps to use winget. My problem it's installing winget itself.
      My Computer


  6. Posts : 4,158
    Windows 11 Pro, 22H2
       #6

    Lokateu said:
    That command works for installing apps from winget. What I wanna know is how to install Winget itself silently, not the apps.

    The basic need of this script is to run a script on a complete default Windows installation and the script install winget to the latest version, install some apps that I need, than verify for updates from microsoft, installs all available updates, restart if needed, and that's it.

    I could find all the steps, except for installing winget itself silently. Always prompt a interface to click update and I need to do it silently.
    That DOES install winget. I tried it on Windows 11. I guess it upgrades winget since it is already included in Win 11. Maybe it's not included in Win 10, so my apologies.
      My Computers


  7. Posts : 790
    Windows 7
       #7

    When you cleanly install Windows, the default version of AppInstaller doesn't include winget. You have to wait a few minutes before WU kicks off, and silently upgrades all UWP (Store) apps in the background. After 10-15 min., AppInstaller will be upgraded and winget is now available.

    If you don't want to wait, then you must force install it. Don't use "ms-appinstaller:?source=https://aka.ms/getwinget" as that shortcut launches AppInstaller (which has no command line, or automation).

    Instead use winget-installer/winget-install.ps1 at master . asheroto/winget-installer . GitHub script.

    It's referenced in the code you've borrowed from Chris Titus' script. asheroto's script installs winget off GitHub, along with its pre-req packages. After it's done, you can call winget to install/upgrade apps.
    Code:
    @echo off
    powershell.exe "irm https://raw.githubusercontent.com/asheroto/winget-installer/master/winget-install.ps1 | iex | Out-Null"
    %LOCALAPPDATA%\Microsoft\WindowsApps\winget.exe
      My Computer


  8. Posts : 46
    Windows 10 23H2
    Thread Starter
       #8

    That almost solved my problem. I got a issue where the winget is not in the latest version and I got to upgrade manually on MStore. Maybe a script that silently updates winget through MStore would solve completely my problem.
      My Computer


  9. Posts : 790
    Windows 7
       #9

    No, the Store version is never the "latest" because it needs to be a super stable branch. And the Store version requires you to have a MS Account (even for free apps) for winget to connect. The GitHub branch has allowed MSA-free access for a year now, it was one of the loudest complaints about winget that MS fixed.

    Why doesn't MS just update the ISO to include a working winget? and why the Store version lags behind... These questions have never been answered.

    You should be using whatever branch is Release Windows Package Manager 1.4.11071 . microsoft/winget-cli . GitHub
    Store versions run in a parallel track, and numbered by release year (2023.417.2324.0)

    Not using the Store version solves several problems:

    1. Don't have a MS Account (local user account only)
    2. Store was removed by a debloating script or tool. GitHub winget can run without any Store, since that's only required for browsing and downloading apps. Normally, WU does all the app updates so there is no reason to keep Store around (unless the user wants it).


    Feel free to solve this problem any way you like, but that's my advice.
      My Computer


  10. Posts : 1,775
    Windows 10 Pro
       #10

    winget - download only?


    Can winget do just downloads and not also do installs?

    I use Revo Uninstaller Pro for all my software installs
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 15:27.
Find Us




Windows 10 Forums