I need a script to SILENTLY install winget

Page 2 of 2 FirstFirst 12

  1. Posts : 785
    Windows 7
       #11

    winget doesn't support any download-only options. But winget packages are provided from the winget repository, or Windows Store.

    - For Windows Store apps, you can use Microsoft Store - Generation Project (v1.2.3) [by @RGAdguard & mkuba50] to download Appx and MSIX packages for most free apps if you know their Product ID names, or the URL from Windows Store's website.

    - For winget repository, you can search the app manifests on Github:
    winget-pkgs/manifests at master . microsoft/winget-pkgs . GitHub

    Each of the manifests contains a direct download URL from the app's publisher. For example, let's take Adobe Reader's installer YAML file:
    Code:
    # Created using wingetcreate 1.2.5.0
    # yaml-language-server: $schema=https://aka.ms/winget-manifest.installer.1.4.0.schema.json
    
    PackageIdentifier: Adobe.Acrobat.Reader.64-bit
    PackageVersion: 23.003.20215
    MinimumOSVersion: 10.0.0.0
    Scope: machine
    InstallModes:
    - interactive
    - silent
    - silentWithProgress
    InstallerSwitches:
      Silent: /sAll /rs /rps /l /re
      SilentWithProgress: /sAll /rs /rps /l /re
    UpgradeBehavior: install
    FileExtensions:
    - pdf
    - pdfa
    - pdfx
    - xfx
    AppsAndFeaturesEntries:
    - DisplayName: Adobe Acrobat DC (64-bit)
      Publisher: Adobe
      ProductCode: '{AC76BA86-1033-FF00-7760-BC15014EA700}'
      InstallerType: msi
    Installers:
    - Architecture: x64
      InstallerType: exe
      InstallerUrl: https://ardownload2.adobe.com/pub/adobe/acrobat/win/AcrobatDC/2300320215/AcroRdrDCx642300320215_MUI.exe
      InstallerSha256: 8A704F83CDC984ACF4AC0C948BDC4FBC5E2CB7C4F5183C8223327A9061BB356F
      ProductCode: '{AC76BA86-1033-FF00-7760-BC15014EA700}'
    ManifestType: installer
    ManifestVersion: 1.4.0

    As you can see, there's nothing special. Everyone else has the same public access to the installer; winget's value is combining both repo and Windows Store sources into a single easy to use package manager.
      My Computer


  2. Posts : 1
    Windows 11
       #12

    This might be too late to be useful for you but posting this anyway in case anyone else stumbles on this thread.

    Here's a script that I was able to get working. It grabs the latest Winget appx package from Microsoft's github repo directly. Hope it helps!

    Code:
    # Check if WinGet is installed; download WinGet if not.
    $wingetPath = "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe"
    if ($Null -eq (Resolve-Path @($wingetPath))) {
        Write-Host "installing WinGet..."
        $latestWingetMsixBundleUri = $(Invoke-RestMethod https://api.github.com/repos/microsoft/winget-cli/releases/latest).assets.browser_download_url | Where-Object {$_.EndsWith(".msixbundle")}
        $latestWingetMsixBundle = $latestWingetMsixBundleUri.Split("/")[-1]
        Write-Information "Downloading winget to artifacts directory..."
        Invoke-WebRequest -Uri $latestWingetMsixBundleUri -OutFile "./$latestWingetMsixBundle"
        Invoke-WebRequest -Uri https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile Microsoft.VCLibs.x64.14.00.Desktop.appx
        Start-Job -Name InstallVCLib -ScriptBlock { Add-AppxPackage Microsoft.VCLibs.x64.14.00.Desktop.appx }
        Wait-Job -Name InstallVCLib
        Start-Job -Name InstallWinGet -ScriptBlock { Add-AppxPackage $latestWingetMsixBundle }
        Wait-Job -Name InstallWinGet
        if ($Null -eq (Resolve-Path @($wingetPath))) {
            Write-Error "Unable to detect WinGet after install. Halting installation. $($_.Exception.Message)"
        }
    }
    Last edited by glantz; 30 Aug 2023 at 17:40. Reason: Removed code that wasn't applicable to the topic
      My Computer


  3. Posts : 2
    Windows 10 LTSC
       #13

    Some minutes ago I've made a ps1 script to install winget and dependencies to my windows LTSC x86 I have now in an old notebook. Then I searched for a similar script and I found this forum thread.
    I need to try in a new installed system because in this one I made command after command with powershell and it worked.
    These are the lines of the script:

    Code:
    Add-AppxPackage Microsoft.VCLibs.x86.14.00.Desktop.appx
    Add-AppxPackage Microsoft.UI.Xaml.2.7.appx
    Add-AppxProvisionedPackage -Online -PackagePath .\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle -LicensePath .\24146eb205d040e69ef2d92d7034d97f_License1.xml -Verbose
    I want to integrate Winget installation in my LTSC installation media somehow, and the first problem I find is that I can't elevate permissions with a cmd line to allow Powershell scripts. I hope I'll find a solution.
      My Computer


  4. Posts : 785
    Windows 7
       #14

    PS command-line to run an elevated PS script, w/o modifying the current Execution Policy:
    Code:
    powershell "Start-Process powershell -Verb Runas -ArgumentList '-NoProfile -ExecutionPolicy Bypass -file C:\path\script.ps1'"
      My Computer


 

  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 09:09.
Find Us




Windows 10 Forums