Merge pull request #386 from KnifMelti/WAU-mods

Custom script (Mods for WAU)
pull/391/head
Romain 2023-09-08 17:06:29 +02:00 committed by GitHub
commit 968d056d76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 1 deletions

View File

@ -171,7 +171,11 @@ Remove scheduled tasks and scripts.
## Intune/SCCM use ## Intune/SCCM use
See https://github.com/Romanitho/Winget-AutoUpdate/discussions/88 See https://github.com/Romanitho/Winget-AutoUpdate/discussions/88
## Custom scripts (Mods feature) ## Custom script (Mods for WAU)
**Mods for WAU** allows you to craft a script to do whatever you like via `_WAU-mods.ps1` in the **mods** folder.
This script executes **if the network is active/any version of Winget is installed/WAU is running as SYSTEM**.
If **ExitCode** is **1** from `_WAU-mods.ps1` then **Re-run WAU**.
## Custom scripts (Mods feature for Apps)
From version 1.8.0, the Mods feature allows you to run additional scripts when upgrading or installing an app. From version 1.8.0, the Mods feature allows you to run additional scripts when upgrading or installing an app.
Just put the scripts in question with the **AppID** followed by the `-preinstall`, `-upgrade`, `-install` or `-installed` suffix in the **mods** folder. Just put the scripts in question with the **AppID** followed by the `-preinstall`, `-upgrade`, `-install` or `-installed` suffix in the **mods** folder.

View File

@ -177,6 +177,21 @@ if (Test-Network) {
Write-ToLog "$DeletedMods Mods deleted (not externally managed) from local path: $($WAUConfig.InstallLocation.TrimEnd(" ", "\"))\mods" "Red" Write-ToLog "$DeletedMods Mods deleted (not externally managed) from local path: $($WAUConfig.InstallLocation.TrimEnd(" ", "\"))\mods" "Red"
} }
} }
#Test if _WAU-mods.ps1 exist: Mods for WAU (if Network is active/any Winget is installed/running as SYSTEM)
$Mods = "$WorkingDir\mods"
if (Test-Path "$Mods\_WAU-mods.ps1") {
Write-ToLog "Running Mods for WAU..." "Yellow"
& "$Mods\_WAU-mods.ps1"
$ModsExitCode = $LASTEXITCODE
#If _WAU-mods.ps1 has ExitCode 1 - Re-run WAU
if ($ModsExitCode -eq 1) {
Write-ToLog "Re-run WAU"
Start-Process powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command `"$WorkingDir\winget-upgrade.ps1`""
Exit
}
}
} }
if ($($WAUConfig.WAU_ListPath) -eq "GPO") { if ($($WAUConfig.WAU_ListPath) -eq "GPO") {

View File

@ -1,3 +1,7 @@
### Mods for WAU (if Network is active/any Winget is installed/running as SYSTEM):
Custom script should be placed here.
A script **Template** `_WAU-mods-template.ps1` is included to get you started.
Rename it to `_WAU-mods.ps1` if you want to activate/run it via `Winget-Upgrade.ps1`.
### Pre/During/Post install/uninstall: ### Pre/During/Post install/uninstall:
Custom scripts should be placed here. Custom scripts should be placed here.
A script **Template** and **Mods Functions** are included as an **example** to get you started... A script **Template** and **Mods Functions** are included as an **example** to get you started...

View File

@ -0,0 +1,19 @@
<# #Mods for WAU (if Network is active/any Winget is installed/running as SYSTEM)
Winget-Upgrade.ps1 calls this script with the code:
[Write-ToLog "Running Mods for WAU..." "Yellow"
& "$Mods\_WAU-mods.ps1"]
Make sure your Functions have unique names!
Exit 1 to Re-run WAU from this script!
#>
<# FUNCTIONS #>
<# ARRAYS/VARIABLES #>
<# MAIN #>
Write-ToLog "...everything's already been done!" "Green"
Exit 0