Minor changes

pull/515/head
romanitho 2023-12-08 00:07:52 +01:00
parent 3f84a5cc6e
commit 21910e63de
3 changed files with 32 additions and 35 deletions

33
Gui.ps1
View File

@ -82,7 +82,9 @@ function Get-WingetAppInfo ($SearchApp) {
#Start Convertion of winget format to an array. Check if "-----" exists
if (!($AppResult -match "-----")) {
Write-Host "No application found."
Start-PopUp "No application found!"
Start-Sleep 2
Close-PopUp
return
}
@ -185,7 +187,7 @@ function Start-Installations {
}
#Install Winget-Autoupdate
Start-Process "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -Command `"$PSScriptRoot\Winget-AutoUpdate-Install.ps1 $WAUParameters`"" -Wait -Verb RunAs
Start-Process "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -Command ""& '$PSScriptRoot\Winget-AutoUpdate-Install.ps1' $WAUParameters""" -Wait -Verb RunAs
}
@ -240,7 +242,7 @@ function Start-Installations {
if ($PopUpWindow) {
#Installs finished
Start-PopUp "Done!"
Start-Sleep 1
Start-Sleep 2
#Close Popup
Close-PopUp
}
@ -272,8 +274,8 @@ function Get-WAUInstallStatus {
$WAUInstalled = $true
}
elseif ($WAUVersion) {
$WAULabelText = "WAU is currently installed (v$WAUVersion) but in another version!"
$WAUStatus = "Orange"
$WAULabelText = "WAU is currently installed but in a different version - v$WAUVersion"
$WAUStatus = "DarkOrange"
$WAUInstalled = $true
}
else {
@ -623,7 +625,9 @@ function Start-InstallGUI {
$response = $SaveFileDialog.ShowDialog() # $response can return OK or Cancel
if ( $response -eq 'OK' ) {
$AppListBox.Items | Out-File $SaveFileDialog.FileName -Append
Write-Host "File saved to:`n$($SaveFileDialog.FileName)"
Start-PopUp "File saved to:`n$($SaveFileDialog.FileName)"
Start-Sleep 2
Close-PopUp
}
}
)
@ -667,7 +671,7 @@ function Start-InstallGUI {
}
else {
Start-PopUp "Please select apps to uninstall..."
Start-Sleep 1
Start-Sleep 2
Close-PopUp
}
}
@ -686,15 +690,14 @@ function Start-InstallGUI {
$LogButton.add_click(
{
if (Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\") {
$LogPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation
try {
$LogPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocatifon
Start-Process "$LogPath\Logs"
}
elseif (Test-Path "$env:programdata\Winget-AutoUpdate\Logs") {
Start-Process "$env:programdata\Winget-AutoUpdate\Logs"
}
else {
Write-Host "Log location not found."
catch {
Start-PopUp "Log location not found."
Start-Sleep 2
Close-PopUp
}
}
)
@ -704,7 +707,7 @@ function Start-InstallGUI {
##
$WAUConfiguratorLinkLabel.Add_PreviewMouseDown(
{
[System.Diagnostics.Process]::Start("https://github.com/Romanitho/Winget-Install-GUI")
[System.Diagnostics.Process]::Start("https://github.com/Romanitho/Winget-AutoUpdate")
}
)

View File

@ -184,6 +184,7 @@ function Install-WingetAutoUpdate {
Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
# Settings for the scheduled task for Updates (System)
Write-ToLog "-> Installing WAU scheduled tasks"
$taskAction = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -File `"$($WAUinstallPath)\winget-upgrade.ps1`""
$taskTriggers = @()
if ($UpdatesAtLogon) {
@ -249,6 +250,7 @@ function Install-WingetAutoUpdate {
$task.SetSecurityDescriptor($sec, 0)
# 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
@ -339,7 +341,12 @@ function Install-WingetAutoUpdate {
}
#Add 1 to counter file
Invoke-RestMethod -Uri "https://github.com/Romanitho/Winget-AutoUpdate/releases/download/v$($WAUVersion)/WAU_InstallCounter" | Out-Null
try {
Invoke-RestMethod -Uri "https://github.com/Romanitho/Winget-AutoUpdate/releases/download/v$($WAUVersion)/WAU_InstallCounter" | Out-Null
}
catch {
Write-ToLog "-> Not able to report installation." "Yellow"
}
Write-ToLog "-> WAU Installation succeeded!`n" "Green"
Start-sleep 1

View File

@ -57,24 +57,6 @@ function Invoke-PostUpdateActions {
Write-ToLog "-> MaxLogFiles/MaxLogSize setting was missing. Fixed with 3/1048576 (in bytes, default is 1048576 = 1 MB)."
}
#Set WAU_ListPath if not set
$ListPath = Get-ItemProperty $regPath -Name WAU_ListPath -ErrorAction SilentlyContinue
if (!$ListPath) {
New-ItemProperty $regPath -Name WAU_ListPath -Force | Out-Null
#log
Write-ToLog "-> ListPath setting was missing. Fixed with empty string."
}
#Set WAU_ModsPath if not set
$ModsPath = Get-ItemProperty $regPath -Name WAU_ModsPath -ErrorAction SilentlyContinue
if (!$ModsPath) {
New-ItemProperty $regPath -Name WAU_ModsPath -Force | Out-Null
#log
Write-ToLog "-> ModsPath setting was missing. Fixed with empty string."
}
#Security check
Write-ToLog "-> Checking Mods Directory:" "yellow"
$Protected = Invoke-DirProtect "$($WAUConfig.InstallLocation)\mods"
@ -183,7 +165,12 @@ function Invoke-PostUpdateActions {
$Script:WAUConfig = Get-WAUConfig
#Add 1 to counter file
Invoke-RestMethod -Uri "https://github.com/Romanitho/Winget-AutoUpdate/releases/download/v$($WAUConfig.DisplayVersion)/WAU_InstallCounter" | Out-Null
try {
Invoke-RestMethod -Uri "https://github.com/Romanitho/Winget-AutoUpdate/releases/download/v$($WAUConfig.DisplayVersion)/WAU_InstallCounter" | Out-Null
}
catch {
Write-ToLog "-> Not able to report installation." "Yellow"
}
#log
Write-ToLog "Post Update actions finished" "green"