Skip to content

Commit 8bc58b1

Browse files
authored
minor changes
1 parent 99a7293 commit 8bc58b1

File tree

2 files changed

+16
-26
lines changed

2 files changed

+16
-26
lines changed

winget-update/winget-notify.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#Send Notif Script
22

33
#get xml notif config
4-
[xml]$NotifConf = Get-Content "C:\ProgramData\winget-update\notif.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
4+
[xml]$NotifConf = Get-Content "$env:ProgramData\winget-update\notif.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
55
if (!($NotifConf)) {break}
66

77
#Load Assemblies

winget-update/winget-upgrade.ps1

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### FUNCTIONS ###
1+
<# FUNCTIONS #>
22

33
function Init {
44
#Var
@@ -62,7 +62,7 @@ function Start-NotifTask ($Title,$Message,$MessageType,$Balise) {
6262
"@
6363

6464
#Save XML File
65-
$ToastTemplateLocation = "C:\ProgramData\winget-update\"
65+
$ToastTemplateLocation = "$env:ProgramData\winget-update\"
6666
if (!(Test-Path $ToastTemplateLocation)){
6767
New-Item -ItemType Directory -Force -Path $ToastTemplateLocation
6868
}
@@ -101,15 +101,15 @@ function Test-Network {
101101
Start-Sleep 10
102102
$timeout += 10
103103
Write-Log "Checking internet connection. $($timeout)s." "Yellow"
104-
}
105-
if ($timeout -eq 300){
106104
#Send Notif if no connection for 5 min
107-
Write-Log "Notify 'No connection'" "Yellow"
108-
$Title = $NotifLocale.local.outputs.output[0].title
109-
$Message = $NotifLocale.local.outputs.output[0].message
110-
$MessageType = "warning"
111-
$Balise = "connection"
112-
Start-NotifTask $Title $Message $MessageType $Balise
105+
if ($timeout -eq 300){
106+
Write-Log "Notify 'No connection'" "Yellow"
107+
$Title = $NotifLocale.local.outputs.output[0].title
108+
$Message = $NotifLocale.local.outputs.output[0].message
109+
$MessageType = "warning"
110+
$Balise = "connection"
111+
Start-NotifTask $Title $Message $MessageType $Balise
112+
}
113113
}
114114
}
115115
Write-Log "Timeout. No internet connection !" "Red"
@@ -207,16 +207,13 @@ function Get-ExcludedApps{
207207
}
208208

209209

210-
211-
### MAIN ###
210+
<# MAIN #>
212211

213212
#Run initialisation
214213
Init
215214

216215
#Check network connectivity
217-
$ping = Test-Network
218-
219-
if ($ping){
216+
if (Test-Network){
220217

221218
#Get exclude apps list
222219
$toSkip = Get-ExcludedApps
@@ -249,17 +246,10 @@ if ($ping){
249246
$Balise = $($app.Name)
250247
Start-NotifTask $Title $Message $MessageType $Balise
251248

252-
#Install update
253-
$Log = "#--- Winget - $($app.Name) Upgrade Starts ---"
254-
$Log | Write-host -ForegroundColor Gray
255-
$Log | out-file -filepath $LogFile -Append
256-
257249
#Winget upgrade
250+
Write-Log "------ Winget - $($app.Name) Upgrade Starts ------" "Gray"
258251
& $upgradecmd upgrade -e --id $($app.Id) --accept-package-agreements --accept-source-agreements -h
259-
260-
$Log = "#--- Winget - $($app.Name) Upgrade Finished ---"
261-
$Log | Write-host -ForegroundColor Gray
262-
$Log | out-file -filepath $LogFile -Append
252+
Write-Log "----- Winget - $($app.Name) Upgrade Finished -----" "Gray"
263253

264254
#Check installed version
265255
$checkoutdated = Get-WingetOutdated
@@ -311,4 +301,4 @@ if ($ping){
311301

312302
#End
313303
Write-Log "End of process!" "Cyan"
314-
Sleep 3
304+
Sleep 3

0 commit comments

Comments
 (0)