Merge pull request #681 from Romanitho/system-apps

Move winget_system_apps.txt to \config folder + Auto Format code
pull/688/head
Romain 2024-09-02 18:31:35 +02:00 committed by GitHub
commit d0334a8561
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
25 changed files with 90 additions and 88 deletions

23
.github/cspell.json vendored
View File

@ -13,7 +13,28 @@
"Notif", "Notif",
"HKLM", "HKLM",
"MSIX", "MSIX",
"msixbundle" "msixbundle",
"notinstalled",
"norestart",
"wekyb*",
"azcopy*",
"Destinationpath",
"Redistributable",
"redist",
"tasktrigger",
"Dont",
"Listpath",
"ncsi",
"msftconnecttest",
"connecttest",
"Balise",
"logfile",
"Uninst",
"inputobject",
"msiexec",
"VERYSILENT",
"SUPPRESSMSGBOXES",
"subfolders"
], ],
"ignorePaths": [ "ignorePaths": [
".github/*", ".github/*",

View File

@ -15,7 +15,7 @@ This project uses the Winget tool to daily update apps (with system context) and
![image](https://user-images.githubusercontent.com/96626929/150645599-9460def4-0818-4fe9-819c-dd7081ff8447.png) ![image](https://user-images.githubusercontent.com/96626929/150645599-9460def4-0818-4fe9-819c-dd7081ff8447.png)
## Intallation ## installation
Just [download latest release (WAU-Configurator.zip)](https://github.com/Romanitho/Winget-AutoUpdate/releases/latest/download/WAU-Configurator.zip), unzip, run "WAU Configurator": Just [download latest release (WAU-Configurator.zip)](https://github.com/Romanitho/Winget-AutoUpdate/releases/latest/download/WAU-Configurator.zip), unzip, run "WAU Configurator":
![WAU Configurator Screenshot](https://github.com/Romanitho/Winget-AutoUpdate/assets/96626929/e3c3a331-1c49-40c5-8f70-e39cf9fc7fd1) ![WAU Configurator Screenshot](https://github.com/Romanitho/Winget-AutoUpdate/assets/96626929/e3c3a331-1c49-40c5-8f70-e39cf9fc7fd1)

View File

@ -92,7 +92,7 @@ function Get-WingetAppInfo ($SearchApp) {
#Search for winget apps #Search for winget apps
$AppResult = & $Winget search $SearchApp --accept-source-agreements --source winget | Out-String $AppResult = & $Winget search $SearchApp --accept-source-agreements --source winget | Out-String
#Start Convertion of winget format to an array. Check if "-----" exists #Start Conversion of winget format to an array. Check if "-----" exists
if (!($AppResult -match "-----")) { if (!($AppResult -match "-----")) {
Start-PopUp "No application found!" Start-PopUp "No application found!"
Start-Sleep 2 Start-Sleep 2
@ -111,7 +111,7 @@ function Get-WingetAppInfo ($SearchApp) {
$fl = $fl - 1 $fl = $fl - 1
#Get header titles [without remove seperator] #Get header titles [without remove separator]
$index = $lines[$fl] -split '(?<=\s)(?!\s)' $index = $lines[$fl] -split '(?<=\s)(?!\s)'
# Line $fl has the header, we can find char where we find ID and Version [and manage non latin characters] # Line $fl has the header, we can find char where we find ID and Version [and manage non latin characters]
@ -129,7 +129,7 @@ function Get-WingetAppInfo ($SearchApp) {
$nameDeclination = $($line.Substring(0, $idStart) -replace '[\u4e00-\u9fa5]', '**').Length - $line.Substring(0, $idStart).Length $nameDeclination = $($line.Substring(0, $idStart) -replace '[\u4e00-\u9fa5]', '**').Length - $line.Substring(0, $idStart).Length
$software.Name = $line.Substring(0, $idStart - $nameDeclination).TrimEnd() $software.Name = $line.Substring(0, $idStart - $nameDeclination).TrimEnd()
$software.Id = $line.Substring($idStart - $nameDeclination, $versionStart - $idStart).TrimEnd() $software.Id = $line.Substring($idStart - $nameDeclination, $versionStart - $idStart).TrimEnd()
#add formated soft to list #add formatted soft to list
$searchList += $software $searchList += $software
} }
} }

View File

@ -263,7 +263,7 @@ function Uninstall-App ($AppID, $AppArgs) {
#Function to Add app to WAU white list #Function to Add app to WAU white list
function Add-WAUWhiteList ($AppID) { function Add-WAUWhiteList ($AppID) {
#Check if WAU default intall path is defined #Check if WAU default install path is defined
if ($WAUInstallLocation) { if ($WAUInstallLocation) {
$WhiteList = "$WAUInstallLocation\included_apps.txt" $WhiteList = "$WAUInstallLocation\included_apps.txt"
#Create included_apps.txt if it doesn't exist #Create included_apps.txt if it doesn't exist
@ -281,7 +281,7 @@ function Add-WAUWhiteList ($AppID) {
#Function to Remove app from WAU white list #Function to Remove app from WAU white list
function Remove-WAUWhiteList ($AppID) { function Remove-WAUWhiteList ($AppID) {
#Check if WAU default intall path exists #Check if WAU default install path exists
$WhiteList = "$WAUInstallLocation\included_apps.txt" $WhiteList = "$WAUInstallLocation\included_apps.txt"
if (Test-Path $WhiteList) { if (Test-Path $WhiteList) {
Write-ToLog "-> Remove $AppID from WAU included_apps.txt" Write-ToLog "-> Remove $AppID from WAU included_apps.txt"

View File

@ -1,4 +1,4 @@
#Function to configure the prefered scope option as Machine #Function to configure the preferred scope option as Machine
function Add-ScopeMachine { function Add-ScopeMachine {
#Get Settings path for system or current user #Get Settings path for system or current user

View File

@ -11,7 +11,7 @@ function Get-WingetOutdatedApps {
#Get list of available upgrades on winget format #Get list of available upgrades on winget format
$upgradeResult = & $Winget upgrade --source winget | Out-String $upgradeResult = & $Winget upgrade --source winget | Out-String
#Start Convertion of winget format to an array. Check if "-----" exists (Winget Error Handling) #Start Conversion of winget format to an array. Check if "-----" exists (Winget Error Handling)
if (!($upgradeResult -match "-----")) { if (!($upgradeResult -match "-----")) {
return "An unusual thing happened (maybe all apps are upgraded):`n$upgradeResult" return "An unusual thing happened (maybe all apps are upgraded):`n$upgradeResult"
} }
@ -28,7 +28,7 @@ function Get-WingetOutdatedApps {
#Get header line #Get header line
$fl = $fl - 1 $fl = $fl - 1
#Get header titles [without remove seperator] #Get header titles [without remove separator]
$index = $lines[$fl] -split '(?<=\s)(?!\s)' $index = $lines[$fl] -split '(?<=\s)(?!\s)'
# Line $fl has the header, we can find char where we find ID and Version [and manage non latin characters] # Line $fl has the header, we can find char where we find ID and Version [and manage non latin characters]
@ -44,7 +44,7 @@ function Get-WingetOutdatedApps {
#Get header line #Get header line
$fl = $i - 1 $fl = $i - 1
#Get header titles [without remove seperator] #Get header titles [without remove separator]
$index = $lines[$fl] -split '(?<=\s)(?!\s)' $index = $lines[$fl] -split '(?<=\s)(?!\s)'
# Line $fl has the header, we can find char where we find ID and Version [and manage non latin characters] # Line $fl has the header, we can find char where we find ID and Version [and manage non latin characters]
@ -61,14 +61,14 @@ function Get-WingetOutdatedApps {
$software.Id = $line.Substring($idStart - $nameDeclination, $versionStart - $idStart).TrimEnd() $software.Id = $line.Substring($idStart - $nameDeclination, $versionStart - $idStart).TrimEnd()
$software.Version = $line.Substring($versionStart - $nameDeclination, $availableStart - $versionStart).TrimEnd() $software.Version = $line.Substring($versionStart - $nameDeclination, $availableStart - $versionStart).TrimEnd()
$software.AvailableVersion = $line.Substring($availableStart - $nameDeclination).TrimEnd() $software.AvailableVersion = $line.Substring($availableStart - $nameDeclination).TrimEnd()
#add formated soft to list #add formatted soft to list
$upgradeList += $software $upgradeList += $software
} }
} }
#If current user is not system, remove system apps from list #If current user is not system, remove system apps from list
if ($IsSystem -eq $false) { if ($IsSystem -eq $false) {
$SystemApps = Get-Content -Path "$WorkingDir\winget_system_apps.txt" -ErrorAction SilentlyContinue $SystemApps = Get-Content -Path "$WorkingDir\config\winget_system_apps.txt" -ErrorAction SilentlyContinue
$upgradeList = $upgradeList | Where-Object { $SystemApps -notcontains $_.Id } $upgradeList = $upgradeList | Where-Object { $SystemApps -notcontains $_.Id }
} }

View File

@ -1,7 +1,7 @@
function Get-WingetSystemApps { function Get-WingetSystemApps {
#Json File, where to export system installed apps #Json File, where to export system installed apps
$jsonFile = "$WorkingDir\winget_system_apps.txt" $jsonFile = "$WorkingDir\config\winget_system_apps.txt"
#Get list of installed Winget apps to json file #Get list of installed Winget apps to json file
& $Winget export -o $jsonFile --accept-source-agreements -s winget | Out-Null & $Winget export -o $jsonFile --accept-source-agreements -s winget | Out-Null

View File

@ -57,7 +57,7 @@ function Install-Prerequisites {
Write-ToLog "-> Microsoft.VCLibs.140.00.UWPDesktop installed successfully." "Green" Write-ToLog "-> Microsoft.VCLibs.140.00.UWPDesktop installed successfully." "Green"
} }
catch { catch {
Write-ToLog "-> Failed to intall Microsoft.VCLibs.140.00.UWPDesktop..." "Red" Write-ToLog "-> Failed to install Microsoft.VCLibs.140.00.UWPDesktop..." "Red"
} }
finally { finally {
Remove-Item -Path $VCLibsFile -Force Remove-Item -Path $VCLibsFile -Force
@ -79,7 +79,7 @@ function Install-Prerequisites {
Write-ToLog "-> Microsoft.UI.Xaml.2.8 installed successfully." "Green" Write-ToLog "-> Microsoft.UI.Xaml.2.8 installed successfully." "Green"
} }
catch { catch {
Write-ToLog "-> Failed to intall Microsoft.UI.Xaml.2.8..." "Red" Write-ToLog "-> Failed to install Microsoft.UI.Xaml.2.8..." "Red"
} }
finally { finally {
Remove-Item -Path $UIXamlFile -Force Remove-Item -Path $UIXamlFile -Force

View File

@ -101,7 +101,9 @@ function Invoke-PostUpdateActions {
"$WorkingDir\functions\Write-Log.ps1", "$WorkingDir\functions\Write-Log.ps1",
"$WorkingDir\functions\Get-WinGetAvailableVersion.ps1", "$WorkingDir\functions\Get-WinGetAvailableVersion.ps1",
"$WorkingDir\functions\Invoke-ModsProtect.ps1", "$WorkingDir\functions\Invoke-ModsProtect.ps1",
"$WorkingDir\Version.txt" "$WorkingDir\functions\Write-CMTraceLog.ps1",
"$WorkingDir\Version.txt",
"$WorkingDir\winget_system_apps.txt"
) )
foreach ($FileName in $FileNames) { foreach ($FileName in $FileNames) {
if (Test-Path $FileName) { if (Test-Path $FileName) {

View File

@ -137,9 +137,6 @@ function Start-NotifTask {
#Save XML to File #Save XML to File
$ToastTemplateLocation = "$($WAUConfig.InstallLocation)\config\" $ToastTemplateLocation = "$($WAUConfig.InstallLocation)\config\"
if (!(Test-Path $ToastTemplateLocation)) {
New-Item -ItemType Directory -Force -Path $ToastTemplateLocation
}
$ToastTemplate.Save("$ToastTemplateLocation\notif.xml") $ToastTemplate.Save("$ToastTemplateLocation\notif.xml")
#Run Notify scheduled task to notify conneted users #Run Notify scheduled task to notify conneted users

View File

@ -13,7 +13,8 @@ function Test-Network {
$ncsiHost = Get-ItemPropertyValue -Path $NlaRegKey -Name ActiveWebProbeHost $ncsiHost = Get-ItemPropertyValue -Path $NlaRegKey -Name ActiveWebProbeHost
$ncsiPath = Get-ItemPropertyValue -Path $NlaRegKey -Name ActiveWebProbePath $ncsiPath = Get-ItemPropertyValue -Path $NlaRegKey -Name ActiveWebProbePath
$ncsiContent = Get-ItemPropertyValue -Path $NlaRegKey -Name ActiveWebProbeContent $ncsiContent = Get-ItemPropertyValue -Path $NlaRegKey -Name ActiveWebProbeContent
} catch { }
catch {
$ncsiHost = "www.msftconnecttest.com" $ncsiHost = "www.msftconnecttest.com"
$ncsiPath = "connecttest.txt" $ncsiPath = "connecttest.txt"
$ncsiContent = "Microsoft Connect Test" $ncsiContent = "Microsoft Connect Test"
@ -22,7 +23,8 @@ function Test-Network {
While ($timeout -lt 1800) { While ($timeout -lt 1800) {
try { try {
$ncsiResponse = Invoke-WebRequest -Uri "http://$($ncsiHost)/$($ncsiPath)" -UseBasicParsing -UserAgent ([Microsoft.PowerShell.Commands.PSUserAgent]::Chrome) $ncsiResponse = Invoke-WebRequest -Uri "http://$($ncsiHost)/$($ncsiPath)" -UseBasicParsing -UserAgent ([Microsoft.PowerShell.Commands.PSUserAgent]::Chrome)
} catch { }
catch {
$ncsiResponse = $false $ncsiResponse = $false
} }

View File

@ -26,7 +26,7 @@ function Write-ToLog {
#If header requested #If header requested
if ($IsHeader) { if ($IsHeader) {
$Log = "#"*65 + "`n#`t$(Get-Date -Format (Get-culture).DateTimeFormat.ShortDatePattern) - $LogMsg`n" + "#"*65 $Log = "#" * 65 + "`n#`t$(Get-Date -Format (Get-culture).DateTimeFormat.ShortDatePattern) - $LogMsg`n" + "#" * 65
} }
else { else {
$Log = "$(Get-Date -UFormat "%T") - $LogMsg" $Log = "$(Get-Date -UFormat "%T") - $LogMsg"

View File

@ -93,7 +93,7 @@ if ($Proc) {
Stop-ModsProc $Proc Stop-ModsProc $Proc
} }
if ($Svc) { if ($Svc) {
Stop-ModsSvc $Svc Stop-ModsSvc $Svc
} }
if ($Wait) { if ($Wait) {
Wait-ModsProc $Wait Wait-ModsProc $Wait

View File

@ -26,10 +26,10 @@ function Stop-ModsProc ($Proc) {
Return Return
} }
function Stop-ModsSvc ($Svc) { function Stop-ModsSvc ($Svc) {
foreach ($service in $Svc) { foreach ($service in $Svc) {
Stop-Service -Name $service -Force -ErrorAction SilentlyContinue | Out-Null Stop-Service -Name $service -Force -ErrorAction SilentlyContinue | Out-Null
} }
Return Return
} }
function Wait-ModsProc ($Wait) { function Wait-ModsProc ($Wait) {
@ -53,93 +53,74 @@ function Uninstall-WingetID ($WingetIDUninst) {
Return Return
} }
function Uninstall-ModsApp ($AppUninst, $AllVersions) function Uninstall-ModsApp ($AppUninst, $AllVersions) {
{ foreach ($app in $AppUninst) {
foreach ($app in $AppUninst)
{
# we start from scanning the x64 node in registry, if something was found, then we set x64=TRUE # we start from scanning the x64 node in registry, if something was found, then we set x64=TRUE
[bool]$app_was_x64 = Process-installedSoftware -app $app -x64 $true; [bool]$app_was_x64 = Process-installedSoftware -app $app -x64 $true;
# if nothing was found in x64 node, then we repeat that action in x86 node # if nothing was found in x64 node, then we repeat that action in x86 node
if (!$app_was_x64) if (!$app_was_x64) {
{
Process-installedSoftware -app $app | Out-Null; Process-installedSoftware -app $app | Out-Null;
} }
} }
Return Return
} }
Function Process-installedSoftware() Function Process-installedSoftware() {
{
[OutputType([Bool])] [OutputType([Bool])]
Param( Param(
[parameter(Mandatory=$true)] [string]$app, [parameter(Mandatory = $true)] [string]$app,
[parameter(Mandatory=$false)][bool] $x64 = $false [parameter(Mandatory = $false)][bool] $x64 = $false
) )
if($true -eq $x64) if ($true -eq $x64) {
{
[string]$path = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall"; [string]$path = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall";
} }
else else {
{
[string]$path = "HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"; [string]$path = "HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall";
} }
[bool]$app_was_found = $false; [bool]$app_was_found = $false;
[Microsoft.Win32.RegistryKey[]]$InstalledSoftware = Get-ChildItem $path; [Microsoft.Win32.RegistryKey[]]$InstalledSoftware = Get-ChildItem $path;
foreach ($obj in $InstalledSoftware) foreach ($obj in $InstalledSoftware) {
{ if ($obj.GetValue('DisplayName') -like $App) {
if ($obj.GetValue('DisplayName') -like $App)
{
$UninstallString = $obj.GetValue('UninstallString') $UninstallString = $obj.GetValue('UninstallString')
$CleanedUninstallString = $UninstallString.Trim([char]0x0022) $CleanedUninstallString = $UninstallString.Trim([char]0x0022)
if ($UninstallString -like "MsiExec.exe*") if ($UninstallString -like "MsiExec.exe*") {
{
$ProductCode = Select-String "{.*}" -inputobject $UninstallString $ProductCode = Select-String "{.*}" -inputobject $UninstallString
$ProductCode = $ProductCode.matches.groups[0].value $ProductCode = $ProductCode.matches.groups[0].value
#MSI x64 Installer #MSI x64 Installer
$Exec = Start-Process "C:\Windows\System32\msiexec.exe" -ArgumentList "/x$ProductCode REBOOT=R /qn" -PassThru -Wait $Exec = Start-Process "C:\Windows\System32\msiexec.exe" -ArgumentList "/x$ProductCode REBOOT=R /qn" -PassThru -Wait
#Stop Hard Reboot (if bad MSI!) #Stop Hard Reboot (if bad MSI!)
if ($Exec.ExitCode -eq 1641) if ($Exec.ExitCode -eq 1641) {
{
Start-Process "C:\Windows\System32\shutdown.exe" -ArgumentList "/a" Start-Process "C:\Windows\System32\shutdown.exe" -ArgumentList "/a"
} }
} }
else else {
{
$QuietUninstallString = $obj.GetValue('QuietUninstallString') $QuietUninstallString = $obj.GetValue('QuietUninstallString')
if ($QuietUninstallString) if ($QuietUninstallString) {
{
$QuietUninstallString = Select-String "(\x22.*\x22) +(.*)" -inputobject $QuietUninstallString $QuietUninstallString = Select-String "(\x22.*\x22) +(.*)" -inputobject $QuietUninstallString
$Command = $QuietUninstallString.matches.groups[1].value $Command = $QuietUninstallString.matches.groups[1].value
$Parameter = $QuietUninstallString.matches.groups[2].value $Parameter = $QuietUninstallString.matches.groups[2].value
#All EXE x64 Installers (already defined silent uninstall) #All EXE x64 Installers (already defined silent uninstall)
Start-Process $Command -ArgumentList $Parameter -Wait Start-Process $Command -ArgumentList $Parameter -Wait
} }
else else {
{ if ((Test-Path $CleanedUninstallString)) {
if ((Test-Path $CleanedUninstallString))
{
$NullSoft = Select-String -Path $CleanedUninstallString -Pattern "Nullsoft" $NullSoft = Select-String -Path $CleanedUninstallString -Pattern "Nullsoft"
} }
if ($NullSoft) if ($NullSoft) {
{
#NSIS x64 Installer #NSIS x64 Installer
Start-Process $UninstallString -ArgumentList "/S" -Wait Start-Process $UninstallString -ArgumentList "/S" -Wait
} }
else else {
{ if ((Test-Path $CleanedUninstallString)) {
if ((Test-Path $CleanedUninstallString))
{
$Inno = Select-String -Path $CleanedUninstallString -Pattern "Inno Setup" $Inno = Select-String -Path $CleanedUninstallString -Pattern "Inno Setup"
} }
if ($Inno) if ($Inno) {
{
#Inno x64 Installer #Inno x64 Installer
Start-Process $UninstallString -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-" -Wait Start-Process $UninstallString -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-" -Wait
} }
else else {
{
Write-Host "$(if($true -eq $x64) {'x64'} else {'x86'}) Uninstaller unknown, trying the UninstallString from registry..." Write-Host "$(if($true -eq $x64) {'x64'} else {'x86'}) Uninstaller unknown, trying the UninstallString from registry..."
$NativeUninstallString = Select-String "(\x22.*\x22) +(.*)" -inputobject $UninstallString $NativeUninstallString = Select-String "(\x22.*\x22) +(.*)" -inputobject $UninstallString
$Command = $NativeUninstallString.matches.groups[1].value $Command = $NativeUninstallString.matches.groups[1].value
@ -151,8 +132,7 @@ Function Process-installedSoftware()
} }
} }
$app_was_found = $true $app_was_found = $true
if (!$AllVersions) if (!$AllVersions) {
{
break break
} }
} }

View File

@ -16,11 +16,11 @@ This all-purpose mod will be overridden by any specific:
<# MAIN #> <# MAIN #>
if ($($app.Id) -eq "Microsoft.SQLServerManagementStudio") { if ($($app.Id) -eq "Microsoft.SQLServerManagementStudio") {
if ($ConfirmInstall -eq $false) { if ($ConfirmInstall -eq $false) {
try { try {
Write-ToLog "...succesfully done something" "Green" Write-ToLog "...successfully done something" "Green"
} }
catch { catch {
Write-ToLog "...failed to do something" "Red" Write-ToLog "...failed to do something" "Red"
} }
} }
} }