Seite 2 von 2

Re: Winget (Desktop App Installer) für Windows Versionen ohne Store installieren (HowTo) [gelöst]

Verfasst: 25.01.2024, 17:46
von Holgi
vlt. möchte jemand auch gleich die Settings.json von Winget bearbeiten lassen? Voila!
Der Forschrittsbalken (z.B.) wird dadurch auf "Rainbow" umgestellt. :smile:

Code: Alles auswählen

@ECHO OFF
::2024-02-06
set /a _Debug=0
chcp 1252 >nul 
::================================================================================================
:: Run Script as Administrator

set _Args=%*
if "%~1" NEQ "" (
  set _Args=%_Args:"=%
)
fltmc >nul || (
  cd /d "%~dp0"
  cmd /u /c echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~dp0"" && ""%~dpnx0"" ""%_Args%""", "", "runas", 1 > "%temp%\GetAdmin.vbs"
  "%temp%\GetAdmin.vbs"
  del /f /q "%temp%\GetAdmin.vbs" 1>nul 2>nul
  exit
)

::================================================================================================


powershell -command "$ProgressPreference = 'SilentlyContinue' ; write-host "Downloade und installiere Abhängigkeiten" ; Invoke-WebRequest -Uri  https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile .\Microsoft.VCLibs.x64.14.00.Desktop.appx ; Invoke-WebRequest -Uri  https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.7.3 -OutFile .\microsoft.ui.xaml.2.7.3.nupkg.zip ; Expand-Archive -Path .\microsoft.ui.xaml.2.7.3.nupkg.zip -Force ; Add-AppXPackage -Path .\microsoft.ui.xaml.2.7.3.nupkg\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.7.appx; Add-AppXPackage -Path .\Microsoft.VCLibs.x64.14.00.Desktop.appx ; write-host "Installiere Winget" ;  Invoke-WebRequest -Uri https://github.com/microsoft/winget-cli/releases/download/v1.6.3482/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle -OutFile .\MicrosoftDesktopAppInstaller_8wekyb3d8bbwe.msixbundle ; Add-AppXPackage -Path .\MicrosoftDesktopAppInstaller_8wekyb3d8bbwe.msixbundle" 2> nul

@SHIFT /0

CLS

echo ======================
echo konfiguriere Settings
echo ====================== & echo.

del "%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json" /f /q

SET NEWLINE=^& echo.
@Echo off

ECHO %NEWLINE%^{>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 
ECHO %NEWLINE%^ "$schema": "https://aka.ms/winget-settings.schema.json",>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 
ECHO %NEWLINE%^   // For documentation on these settings, see: https://aka.ms/winget-settings>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json  
ECHO %NEWLINE%^ "source": {>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 
ECHO %NEWLINE%^ "autoUpdateIntervalInMinutes": 5 >>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 
ECHO %NEWLINE%^ },>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 
 
ECHO %NEWLINE%^ "visual": {>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 
ECHO %NEWLINE%^    "progressBar": "rainbow">>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 
ECHO %NEWLINE%^},>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 

ECHO %NEWLINE%^ "experimentalFeatures": {>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 
ECHO %NEWLINE%^    "uninstall": true,>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 
ECHO %NEWLINE%^    "upgrade": true,>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 
ECHO %NEWLINE%^    "list": true,>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 
ECHO %NEWLINE%^    "experimentalMSStore": true>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 
ECHO %NEWLINE%^  },>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 
 
ECHO %NEWLINE%^ "telemetry": {>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 
ECHO %NEWLINE%^    "disable": true>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 
ECHO %NEWLINE%^},>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 

ECHO %NEWLINE%^ "installBehavior": {>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 
ECHO %NEWLINE%^    "preferences": {>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 
ECHO %NEWLINE%^        "locale": [ "de-DE", "en-US" ]>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 
ECHO %NEWLINE%^    }>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 
ECHO %NEWLINE%^},>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 
 
ECHO %NEWLINE%^ "installBehavior": {>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 
ECHO %NEWLINE%^    "preferences": {>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 
ECHO %NEWLINE%^        "scope": "user">>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 
ECHO %NEWLINE%^    }>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 
ECHO %NEWLINE%^}>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 
ECHO %NEWLINE%^}>>%localAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json 

cls

ECHO.
ECHO  - fertisch!!
ECHO.
rem timeout -1
winget list --accept-source-agreements
pause

@EXIT

Re: Winget (Desktop App Installer) für Windows Versionen ohne Store installieren (HowTo) [gelöst]

Verfasst: 25.01.2024, 17:55
von DK2000
Die Settings.json könnte man ja auch so bearbeiten. Meine sieht da auch ganz anders mittlerweile aus:

Code: Alles auswählen

{
  "$schema": "https://aka.ms/winget-settings.schema.json",
  "visual": {
    "progressBar": "rainbow",
    "anonymizeDisplayedPaths": true
  },
  "source": {
    "autoUpdateIntervalInMinutes": 120
  },
  "network": {
    "downloader": "do",
    "doProgressTimeoutInSeconds": 60
  },
  "installBehavior": {
    "portablePackageUserRoot": "C:/Users/*****/AppData/Local/Programs/winget",
    "portablePackageMachineRoot": "C:/Program Files/winget",
    "disableInstallNotes": true,
    "preferences": {
      "locale": [
        "de-DE",
        "en-US"
      ],
      "architectures": [
        "x64",
        "x86"
      ]
    }
  },
  "uninstallBehavior": {
    "purgePortablePackage": true
  },
  "telemetry": {
    "disable": true
  },
  "logging": {
    "level": "info"
  }
}
Das in einen Batch zu packen, wäre mir da zu kompliziert.

Re: Winget (Desktop App Installer) für Windows Versionen ohne Store installieren (HowTo) [gelöst]

Verfasst: 25.01.2024, 18:30
von Holgi
DK2000 hat geschrieben: 25.01.2024, 17:55 Die Settings.json könnte man ja auch so bearbeiten.
Das in einen Batch zu packen, wäre mir da zu kompliziert.
Weißt ja; bei mir muss immer alles automatisiert ablaufen ;)

Re: Winget (Desktop App Installer) für Windows Versionen ohne Store installieren (HowTo) [gelöst]

Verfasst: 25.01.2024, 18:45
von DK2000
Ja, aber in so eine Falle pflege ich da die Konfigurationsdateien einzeln und packe die in ein Repository. Von da aus kopiere ich die dann manuell oder per cmd/ps1 an ihr Ziel. Die ganzen Dateien als Batch mit Echo neu erstellen, wäre mir da viel zu viel Aufwand.

Re: Winget (Desktop App Installer) für Windows Versionen ohne Store installieren (HowTo) [gelöst]

Verfasst: 25.01.2024, 18:50
von Holgi
DK2000 hat geschrieben: 25.01.2024, 18:45 Ja, aber in so eine Falle pflege ich da die Konfigurationsdateien einzeln und packe die in ein Repository. Von da aus kopiere ich die dann manuell oder per cmd/ps1 an ihr Ziel.
mach in normalerweise auch so.
Diese Batch sollte für User sein, die noch gar kein Winget und infolgedessen auch noch keine settings.json haben.

Re: Winget (Desktop App Installer) für Windows Versionen ohne Store installieren (HowTo) [gelöst]

Verfasst: 05.05.2024, 17:04
von Holgi
Die oben genannten Methoden, um bei einer Windows Installation Winget nachzuinstallieren (falls nicht schon vorhanden) haben einen gemeinsamen Nachteil:
die Abhängigkeiten sind fest verankert (z.B. UI-XAML 2.7 bzw. 2.8) und destawegen nicht immer auf dem neuesten Stand.
Deshalb hier noch eine neue Version, die auf dem Script hier: https://github.com/asheroto/winget-install aufbaut.
getestet von mir in einer Windows Sandbox.
Als nächstes werde ich mal schauen, ob das auch in einer SetupComplete.cmd (Firstlogon.cmd) funktioniert.
Nacheinander die folgenden Befehle in die Kommandozeile (cmd) (Adminrechte) hämmern:

Code: Alles auswählen

powershell Install-PackageProvider -Name "NuGet" -Force
powershell Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
powershell Install-Script -Name winget-install -force
PowerShell.exe -NoProfile -Command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File """C:\Program Files\WindowsPowerShell\Scripts\winget-install.ps1""' -Verb RunAs}"
Bei der letzten Zeile bin ich mir nicht sicher, ob das nicht auch einfacher geht. Leider fehlen mir die Powershell-Kenntnisse, um das zu kürzen (wenn es denn überhaupt kürzer geht).
Vlt. kann jemand, der hier mitliest (@DK2000, @g-force?) da drauf eingehen und es umschreiben?
Apropo:
das Zeilen funktionieren zwar auch so; aber an welcher Stelle müßte man die möglichen Schalter zu dem Script "winget-install.ps1" in die letzte Zeile einfügen?
es gibt z.B. diese Schalter:
-Debug
Enables debug mode, which shows additional information for debugging.
-Force
Ensures installation of winget and its dependencies, even if already present.
-ForceClose
Relaunches the script in conhost.exe and automatically ends active processes associated with winget that could interfere with the installation.
-Wait
Forces the script to wait several seconds before exiting.
-UpdateSelf
Updates the script to the latest version on PSGallery.
-CheckForUpdate
Checks if there is an update available for the script.
-Version
Displays the version of the script.
-Help
Displays the full help information for the script

Wenn alle Befehle abgesetzt sind, dann sollte

Code: Alles auswählen

winget list --accept-source-agreements
funktionieren.