Skip to content

Commit

Permalink
Migrate Reg Config
Browse files Browse the repository at this point in the history
  • Loading branch information
Romanitho committed Jul 18, 2024
1 parent 87715a3 commit 8e58617
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 85 deletions.
8 changes: 4 additions & 4 deletions Sources/WAU/Gui.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ function Start-Installations {
#Run Winget-Install script if box is checked
if ($AppToInstall) {
Start-PopUp "Installing applications..."
$WAUInstallPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation
$WAUInstallPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\" -Name InstallLocation

#Try with admin rights.
try {
Expand Down Expand Up @@ -275,7 +275,7 @@ function Start-Uninstallations ($AppToUninstall) {
}

function Get-WAUInstallStatus {
$WAUVersion = Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\ -ErrorAction SilentlyContinue | Select-Object -ExpandProperty DisplayVersion -ErrorAction SilentlyContinue
$WAUVersion = Get-ItemProperty -Path HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\ -ErrorAction SilentlyContinue | Select-Object -ExpandProperty DisplayVersion -ErrorAction SilentlyContinue
if ($WAUVersion -eq $WAUConfiguratorVersion) {
$WAULabelText = "WAU is currently installed (v$WAUVersion)."
$WAUStatus = "Green"
Expand Down Expand Up @@ -577,7 +577,7 @@ function Start-InstallGUI {
$UninstallWAUButton.add_click(
{
#Uninstall WAU from registry command
$Arguments = Get-ItemPropertyValue "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name "UninstallString"
$Arguments = Get-ItemPropertyValue "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name "UninstallString"
Start-Process "cmd.exe" -ArgumentList "/c $Arguments" -Wait -Verb RunAs
$WAUInstallStatus = Get-WAUInstallStatus
$WAUStatusLabel.Text = $WAUInstallStatus[0]
Expand Down Expand Up @@ -699,7 +699,7 @@ function Start-InstallGUI {
$LogButton.add_click(
{
try {
$LogPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocatifon
$LogPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\" -Name InstallLocatifon
Start-Process "$LogPath\Logs"
}
catch {
Expand Down
27 changes: 16 additions & 11 deletions Sources/WAU/Winget-AutoUpdate-Install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -252,16 +252,19 @@ function Install-WingetAutoUpdate {
# Configure Reg Key
Write-ToLog "-> Setting Registry config"
New-Item $regPath -Force | Out-Null
New-ItemProperty $regPath -Name DisplayName -Value "Winget-AutoUpdate (WAU)" -Force | Out-Null
New-ItemProperty $regPath -Name DisplayIcon -Value "C:\Windows\System32\shell32.dll,-16739" -Force | Out-Null
New-ItemProperty $regPath -Name DisplayVersion -Value $WAUVersion -Force | Out-Null
New-Item $InstallregPath -Force | Out-Null
New-ItemProperty $InstallregPath -Name DisplayName -Value "Winget-AutoUpdate (WAU)" -Force | Out-Null
New-ItemProperty $InstallregPath -Name DisplayIcon -Value "C:\Windows\System32\shell32.dll,-16739" -Force | Out-Null
New-ItemProperty $InstallregPath -Name DisplayVersion -Value $WAUVersion -Force | Out-Null
New-ItemProperty $regPath -Name ProductVersion -Value $WAUVersion -Force | Out-Null
New-ItemProperty $InstallregPath -Name InstallLocation -Value $WAUinstallPath -Force | Out-Null
New-ItemProperty $regPath -Name InstallLocation -Value $WAUinstallPath -Force | Out-Null
New-ItemProperty $regPath -Name UninstallString -Value "powershell.exe -noprofile -executionpolicy bypass -file `"$WAUinstallPath\WAU-Uninstall.ps1`"" -Force | Out-Null
New-ItemProperty $regPath -Name QuietUninstallString -Value "powershell.exe -noprofile -executionpolicy bypass -file `"$WAUinstallPath\WAU-Uninstall.ps1`"" -Force | Out-Null
New-ItemProperty $regPath -Name NoModify -Value 1 -Force | Out-Null
New-ItemProperty $regPath -Name NoRepair -Value 1 -Force | Out-Null
New-ItemProperty $regPath -Name Publisher -Value "Romanitho" -Force | Out-Null
New-ItemProperty $regPath -Name URLInfoAbout -Value "https://github.com/Romanitho/Winget-AutoUpdate" -Force | Out-Null
New-ItemProperty $InstallregPath -Name UninstallString -Value "powershell.exe -noprofile -executionpolicy bypass -file `"$WAUinstallPath\WAU-Uninstall.ps1`"" -Force | Out-Null
New-ItemProperty $InstallregPath -Name QuietUninstallString -Value "powershell.exe -noprofile -executionpolicy bypass -file `"$WAUinstallPath\WAU-Uninstall.ps1`"" -Force | Out-Null
New-ItemProperty $InstallregPath -Name NoModify -Value 1 -Force | Out-Null
New-ItemProperty $InstallregPath -Name NoRepair -Value 1 -Force | Out-Null
New-ItemProperty $InstallregPath -Name Publisher -Value "Romanitho" -Force | Out-Null
New-ItemProperty $InstallregPath -Name URLInfoAbout -Value "https://github.com/Romanitho/Winget-AutoUpdate" -Force | Out-Null
New-ItemProperty $regPath -Name WAU_NotificationLevel -Value $NotificationLevel -Force | Out-Null
if ($WAUVersion -match "-") {
New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value 1 -PropertyType DWord -Force | Out-Null
Expand Down Expand Up @@ -366,7 +369,7 @@ function Uninstall-WingetAutoUpdate {
Write-ToLog "Uninstalling WAU started!" "Yellow"

#Get registry install location
$InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation -ErrorAction SilentlyContinue
$InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\" -Name InstallLocation -ErrorAction SilentlyContinue

#Check if installed location exists and delete
if ($InstallLocation) {
Expand All @@ -389,6 +392,7 @@ function Uninstall-WingetAutoUpdate {
}
& reg delete "HKCR\AppUserModelId\Windows.SystemToast.Winget.Notification" /f | Out-Null
& reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" /f | Out-Null
& reg delete "HKLM\SOFTWARE\Romanitho\Winget-AutoUpdate" /f | Out-Null

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
Expand Down Expand Up @@ -493,7 +497,8 @@ Write-Host "`t https://github.com/Romanitho/Winget-AutoUpdate`n" -Foreground
Write-Host "`t________________________________________________________`n"

#Define WAU registry key
$Script:regPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"
$Script:regPath = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate"
$Script:InstallregPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"

if (!$Uninstall) {
Write-ToLog " INSTALLING WAU" -LogColor "Cyan" -IsHeader
Expand Down
4 changes: 2 additions & 2 deletions Sources/WAU/Winget-AutoUpdate/WAU-Policies.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Daily update settings from policies
$ActivateGPOManagement = Get-ItemPropertyValue "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "WAU_ActivateGPOManagement" -ErrorAction SilentlyContinue
if ($ActivateGPOManagement -eq 1) {
#Add (or update) tag to activate WAU-Policies Management
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name WAU_RunGPOManagement -Value 1 -Force | Out-Null
New-ItemProperty "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name WAU_RunGPOManagement -Value 1 -Force | Out-Null
}

#Get WAU settings
Expand All @@ -32,7 +32,7 @@ if ($WAUConfig.WAU_RunGPOManagement -eq 1) {
Add-Content -Path $GPOLogFile -Value "GPO Management Enabled. Policies updated."
}
else {
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name WAU_RunGPOManagement -Value 0 -Force | Out-Null
New-ItemProperty "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name WAU_RunGPOManagement -Value 0 -Force | Out-Null
$WAUConfig.WAU_RunGPOManagement = 0
Add-Content -Path $GPOLogFile -Value "GPO Management Disabled. Policies removed."
}
Expand Down
3 changes: 2 additions & 1 deletion Sources/WAU/Winget-AutoUpdate/WAU-Uninstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Write-Host "`t________________________________________________________`n`n"
try {
Write-host "Uninstalling WAU..." -ForegroundColor Yellow
#Get registry install location
$InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation
$InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\" -Name InstallLocation

#Check if installed location exists and delete
if (Test-Path ($InstallLocation)) {
Expand All @@ -53,6 +53,7 @@ try {
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 "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" /f | Out-Null
& reg delete "HKLM\SOFTWARE\Romanitho\Winget-AutoUpdate" /f | Out-Null
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
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/WAU/Winget-AutoUpdate/Winget-Install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ $CurrentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Pri
$Script:IsElevated = $CurrentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)

#Get WAU Installed location
$WAURegKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\"
$WAURegKey = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\"
$Script:WAUInstallLocation = Get-ItemProperty $WAURegKey -ErrorAction SilentlyContinue | Select-Object -ExpandProperty InstallLocation

#LogPath initialisation
Expand Down
2 changes: 1 addition & 1 deletion Sources/WAU/Winget-AutoUpdate/Winget-Notify.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#Send Notify Script

#get xml notif config
$WAUinstalledPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation
$WAUinstalledPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\" -Name InstallLocation
[xml]$NotifConf = Get-Content "$WAUinstalledPath\config\notif.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
if (!($NotifConf)) {
break
Expand Down
2 changes: 1 addition & 1 deletion Sources/WAU/Winget-AutoUpdate/Winget-Upgrade.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ if (Test-Network) {
Write-ToLog "Winget Version: $WingetVer"

#Get Current Version
$WAUCurrentVersion = $WAUConfig.DisplayVersion
$WAUCurrentVersion = $WAUConfig.ProductVersion
Write-ToLog "WAU current version: $WAUCurrentVersion"
if ($IsSystem) {
#Check if WAU update feature is enabled or not if run as System
Expand Down
2 changes: 1 addition & 1 deletion Sources/WAU/Winget-AutoUpdate/functions/Get-WAUConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Function Get-WAUConfig {

#Get WAU Configurations from install config
$WAUConfig = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -ErrorAction SilentlyContinue
$WAUConfig = Get-ItemProperty -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -ErrorAction SilentlyContinue

#Check if GPO Management is enabled
$ActivateGPOManagement = Get-ItemPropertyValue "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "WAU_ActivateGPOManagement" -ErrorAction SilentlyContinue
Expand Down
Loading

0 comments on commit 8e58617

Please sign in to comment.