Revert "Move registry keys to future location"

This reverts commit e16c12e456.
pull/671/head
Romain 2024-08-31 14:29:00 +02:00
parent e16c12e456
commit 062c4f2541
10 changed files with 22 additions and 35 deletions

View File

@ -204,7 +204,7 @@ function Start-Installations {
#Run Winget-Install script if box is checked #Run Winget-Install script if box is checked
if ($AppToInstall) { if ($AppToInstall) {
Start-PopUp "Installing applications..." Start-PopUp "Installing applications..."
$WAUInstallPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\" -Name InstallLocation $WAUInstallPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation
#Try with admin rights. #Try with admin rights.
try { try {
@ -275,7 +275,7 @@ function Start-Uninstallations ($AppToUninstall) {
} }
function Get-WAUInstallStatus { function Get-WAUInstallStatus {
$WAUVersion = Get-ItemProperty -Path HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\ -ErrorAction SilentlyContinue | Select-Object -ExpandProperty DisplayVersion -ErrorAction SilentlyContinue $WAUVersion = Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\ -ErrorAction SilentlyContinue | Select-Object -ExpandProperty DisplayVersion -ErrorAction SilentlyContinue
if ($WAUVersion -eq $WAUConfiguratorVersion) { if ($WAUVersion -eq $WAUConfiguratorVersion) {
$WAULabelText = "WAU is currently installed (v$WAUVersion)." $WAULabelText = "WAU is currently installed (v$WAUVersion)."
$WAUStatus = "Green" $WAUStatus = "Green"
@ -577,7 +577,7 @@ function Start-InstallGUI {
$UninstallWAUButton.add_click( $UninstallWAUButton.add_click(
{ {
#Uninstall WAU from registry command #Uninstall WAU from registry command
$Arguments = Get-ItemPropertyValue "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name "UninstallString" $Arguments = Get-ItemPropertyValue "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name "UninstallString"
Start-Process "cmd.exe" -ArgumentList "/c $Arguments" -Wait -Verb RunAs Start-Process "cmd.exe" -ArgumentList "/c $Arguments" -Wait -Verb RunAs
$WAUInstallStatus = Get-WAUInstallStatus $WAUInstallStatus = Get-WAUInstallStatus
$WAUStatusLabel.Text = $WAUInstallStatus[0] $WAUStatusLabel.Text = $WAUInstallStatus[0]
@ -699,7 +699,7 @@ function Start-InstallGUI {
$LogButton.add_click( $LogButton.add_click(
{ {
try { try {
$LogPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\" -Name InstallLocatifon $LogPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocatifon
Start-Process "$LogPath\Logs" Start-Process "$LogPath\Logs"
} }
catch { catch {

View File

@ -361,7 +361,7 @@ function Uninstall-WingetAutoUpdate {
Write-ToLog "Uninstalling WAU started!" "Yellow" Write-ToLog "Uninstalling WAU started!" "Yellow"
#Get registry install location #Get registry install location
$InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\" -Name InstallLocation -ErrorAction SilentlyContinue $InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation -ErrorAction SilentlyContinue
#Check if installed location exists and delete #Check if installed location exists and delete
if ($InstallLocation) { if ($InstallLocation) {
@ -383,7 +383,7 @@ function Uninstall-WingetAutoUpdate {
Get-ChildItem -Path $InstallLocation -Exclude *.txt, mods, logs | Remove-Item -Recurse -Force Get-ChildItem -Path $InstallLocation -Exclude *.txt, mods, logs | Remove-Item -Recurse -Force
} }
& reg delete "HKCR\AppUserModelId\Windows.SystemToast.Winget.Notification" /f | Out-Null & reg delete "HKCR\AppUserModelId\Windows.SystemToast.Winget.Notification" /f | Out-Null
& reg delete "HKLM\SOFTWARE\Romanitho\Winget-AutoUpdate" /f | Out-Null & reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" /f | Out-Null
if ((Test-Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)")) { if ((Test-Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)")) {
Remove-Item -Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)" -Recurse -Force | Out-Null Remove-Item -Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)" -Recurse -Force | Out-Null
@ -488,7 +488,7 @@ Write-Host "`t https://github.com/Romanitho/Winget-AutoUpdate`n" -Foreground
Write-Host "`t________________________________________________________`n" Write-Host "`t________________________________________________________`n"
#Define WAU registry key #Define WAU registry key
$Script:regPath = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" $Script:regPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"
if (!$Uninstall) { if (!$Uninstall) {
Write-ToLog " INSTALLING WAU" -LogColor "Cyan" -IsHeader Write-ToLog " INSTALLING WAU" -LogColor "Cyan" -IsHeader

View File

@ -14,7 +14,7 @@ Daily update settings from policies
$ActivateGPOManagement = Get-ItemPropertyValue "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "WAU_ActivateGPOManagement" -ErrorAction SilentlyContinue $ActivateGPOManagement = Get-ItemPropertyValue "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "WAU_ActivateGPOManagement" -ErrorAction SilentlyContinue
if ($ActivateGPOManagement -eq 1) { if ($ActivateGPOManagement -eq 1) {
#Add (or update) tag to activate WAU-Policies Management #Add (or update) tag to activate WAU-Policies Management
New-ItemProperty "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name WAU_RunGPOManagement -Value 1 -Force | Out-Null New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name WAU_RunGPOManagement -Value 1 -Force | Out-Null
} }
#Get WAU settings #Get WAU settings
@ -32,7 +32,7 @@ if ($WAUConfig.WAU_RunGPOManagement -eq 1) {
Add-Content -Path $GPOLogFile -Value "GPO Management Enabled. Policies updated." Add-Content -Path $GPOLogFile -Value "GPO Management Enabled. Policies updated."
} }
else { else {
New-ItemProperty "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name WAU_RunGPOManagement -Value 0 -Force | Out-Null New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name WAU_RunGPOManagement -Value 0 -Force | Out-Null
$WAUConfig.WAU_RunGPOManagement = 0 $WAUConfig.WAU_RunGPOManagement = 0
Add-Content -Path $GPOLogFile -Value "GPO Management Disabled. Policies removed." Add-Content -Path $GPOLogFile -Value "GPO Management Disabled. Policies removed."
} }

View File

@ -35,7 +35,7 @@ Write-Host "`t________________________________________________________`n`n"
try { try {
Write-host "Uninstalling WAU..." -ForegroundColor Yellow Write-host "Uninstalling WAU..." -ForegroundColor Yellow
#Get registry install location #Get registry install location
$InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\" -Name InstallLocation $InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation
#Check if installed location exists and delete #Check if installed location exists and delete
if (Test-Path ($InstallLocation)) { if (Test-Path ($InstallLocation)) {
@ -52,7 +52,7 @@ try {
Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
Get-ScheduledTask -TaskName "Winget-AutoUpdate-Policies" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False Get-ScheduledTask -TaskName "Winget-AutoUpdate-Policies" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
& reg delete "HKCR\AppUserModelId\Windows.SystemToast.Winget.Notification" /f | Out-Null & reg delete "HKCR\AppUserModelId\Windows.SystemToast.Winget.Notification" /f | Out-Null
& reg delete "HKLM\SOFTWARE\Romanitho\Winget-AutoUpdate" /f | Out-Null & reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" /f | Out-Null
if (Test-Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate") { if (Test-Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate") {
& reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" /f | Out-Null & reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" /f | Out-Null
} }

View File

@ -311,7 +311,7 @@ $CurrentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Pri
$Script:IsElevated = $CurrentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) $Script:IsElevated = $CurrentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
#Get WAU Installed location #Get WAU Installed location
$WAURegKey = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\" $WAURegKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\"
$Script:WAUInstallLocation = Get-ItemProperty $WAURegKey -ErrorAction SilentlyContinue | Select-Object -ExpandProperty InstallLocation $Script:WAUInstallLocation = Get-ItemProperty $WAURegKey -ErrorAction SilentlyContinue | Select-Object -ExpandProperty InstallLocation
#LogPath initialisation #LogPath initialisation

View File

@ -1,7 +1,7 @@
#Send Notify Script #Send Notify Script
#get xml notif config #get xml notif config
$WAUinstalledPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\" -Name InstallLocation $WAUinstalledPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation
[xml]$NotifConf = Get-Content "$WAUinstalledPath\config\notif.xml" -Encoding UTF8 -ErrorAction SilentlyContinue [xml]$NotifConf = Get-Content "$WAUinstalledPath\config\notif.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
if (!($NotifConf)) { if (!($NotifConf)) {
break break

View File

@ -3,7 +3,7 @@
Function Get-WAUConfig { Function Get-WAUConfig {
#Get WAU Configurations from install config #Get WAU Configurations from install config
$WAUConfig = Get-ItemProperty -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -ErrorAction SilentlyContinue $WAUConfig = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -ErrorAction SilentlyContinue
#Check if GPO Management is enabled #Check if GPO Management is enabled
$ActivateGPOManagement = Get-ItemPropertyValue "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "WAU_ActivateGPOManagement" -ErrorAction SilentlyContinue $ActivateGPOManagement = Get-ItemPropertyValue "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "WAU_ActivateGPOManagement" -ErrorAction SilentlyContinue

View File

@ -9,7 +9,7 @@ function Invoke-PostUpdateActions {
$null = Update-WinGet $null = Update-WinGet
#Create WAU Regkey if not present #Create WAU Regkey if not present
$regPath = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" $regPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"
if (!(test-path $regPath)) { if (!(test-path $regPath)) {
New-Item $regPath -Force New-Item $regPath -Force
New-ItemProperty $regPath -Name DisplayName -Value "Winget-AutoUpdate (WAU)" -Force New-ItemProperty $regPath -Name DisplayName -Value "Winget-AutoUpdate (WAU)" -Force
@ -113,8 +113,8 @@ function Invoke-PostUpdateActions {
} }
#Remove old registry key #Remove old registry key
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name "VersionMajor" -ErrorAction SilentlyContinue Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name "VersionMajor" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name "VersionMinor" -ErrorAction SilentlyContinue Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name "VersionMinor" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "VersionMajor" -ErrorAction SilentlyContinue Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "VersionMajor" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "VersionMinor" -ErrorAction SilentlyContinue Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "VersionMinor" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "DisplayVersion" -ErrorAction SilentlyContinue Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "DisplayVersion" -ErrorAction SilentlyContinue
@ -143,24 +143,11 @@ function Invoke-PostUpdateActions {
Write-ToLog "-> Policies task created." Write-ToLog "-> Policies task created."
} }
#Migrate registry to new location (MSI Prerequisites)
$sourcePath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"
$destinationPath = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate"
if (-not (Test-Path (Split-Path $destinationPath))) {
New-Item -Path (Split-Path $destinationPath) -ItemType Directory
}
try {
Move-Item -Path $sourcePath -Destination $destinationPath -Force
Write-ToLog "-> Migrated registry from $sourcePath to $destinationPath."
}
catch {
Write-ToLog "-> Failed tro migrate registry to new location"
}
### End of post update actions ### ### End of post update actions ###
#Reset WAU_UpdatePostActions Value #Reset WAU_UpdatePostActions Value
New-ItemProperty -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name "WAU_PostUpdateActions" -Value 0 -Force | Out-Null New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name "WAU_PostUpdateActions" -Value 0 -Force | Out-Null
#Get updated WAU Config #Get updated WAU Config
$Script:WAUConfig = Get-WAUConfig $Script:WAUConfig = Get-WAUConfig

View File

@ -46,10 +46,10 @@ function Update-WAU {
Remove-Item -Path $location -Recurse -Force -ErrorAction SilentlyContinue Remove-Item -Path $location -Recurse -Force -ErrorAction SilentlyContinue
#Set new version to registry #Set new version to registry
New-ItemProperty -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name "DisplayVersion" -Value $WAUAvailableVersion -Force | Out-Null New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name "DisplayVersion" -Value $WAUAvailableVersion -Force | Out-Null
#Set Post Update actions to 1 #Set Post Update actions to 1
New-ItemProperty -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name "WAU_PostUpdateActions" -Value 1 -Force | Out-Null New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name "WAU_PostUpdateActions" -Value 1 -Force | Out-Null
#Send success Notif #Send success Notif
Write-ToLog "WAU Update completed." "Green" Write-ToLog "WAU Update completed." "Green"

View File

@ -35,7 +35,7 @@ $AllVersions = $False
$Lnk = @("") $Lnk = @("")
#Registry _value_ (DWord/String) to add in existing registry Key (Key created if not existing). Example: #Registry _value_ (DWord/String) to add in existing registry Key (Key created if not existing). Example:
#$AddKey = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" #$AddKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"
#$AddValue = "WAU_BypassListForUsers" #$AddValue = "WAU_BypassListForUsers"
#$AddTypeData = "1" #$AddTypeData = "1"
#$AddType = "DWord" #$AddType = "DWord"
@ -46,7 +46,7 @@ $AddType = ""
#Registry _value_ to delete in existing registry Key. #Registry _value_ to delete in existing registry Key.
#Value can be omitted for deleting entire Key!. Example: #Value can be omitted for deleting entire Key!. Example:
#$DelKey = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" #$DelKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"
#$DelValue = "WAU_BypassListForUsers" #$DelValue = "WAU_BypassListForUsers"
$DelKey = "" $DelKey = ""
$DelValue = "" $DelValue = ""