Merge pull request #437 from Romanitho/ServiceUIv2

ServiceUI added to handle some apps
pull/438/head
Romain 2023-10-19 19:11:37 +02:00 committed by GitHub
commit 15e8508d88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 44 additions and 7 deletions

View File

@ -82,11 +82,19 @@ jobs:
- name: Build project - name: Build project
run: | run: |
# Get MDT from Microsoft
wget https://download.microsoft.com/download/3/3/9/339BE62D-B4B8-4956-B58D-73C4685FC492/MicrosoftDeploymentToolkit_x64.msi
# Extract MSI
7z x MicrosoftDeploymentToolkit_x64.msi
# Copy ServiceUI.exe to Winget-AutoUpdate folder
mv Modena_File206 Winget-AutoUpdate/ServiceUI.exe
# Zip WAU
zip -r WAU.zip Winget-AutoUpdate zip -r WAU.zip Winget-AutoUpdate
zip WAU.zip Winget-AutoUpdate-Install.ps1 zip WAU.zip Winget-AutoUpdate-Install.ps1
zip WAU.zip excluded_apps.txt zip WAU.zip excluded_apps.txt
zip WAU.zip install.bat zip WAU.zip install.bat
zip WAU.zip uninstall.bat zip WAU.zip uninstall.bat
# Zip ADMX
cd Policies cd Policies
zip -r ../WAU_ADMX.zip * zip -r ../WAU_ADMX.zip *
cd .. cd ..

View File

@ -55,11 +55,19 @@ jobs:
- name: Build project - name: Build project
run: | run: |
# Get MDT from Microsoft
wget https://download.microsoft.com/download/3/3/9/339BE62D-B4B8-4956-B58D-73C4685FC492/MicrosoftDeploymentToolkit_x64.msi
# Extract MSI
7z x MicrosoftDeploymentToolkit_x64.msi
# Copy ServiceUI.exe to Winget-AutoUpdate folder
mv Modena_File206 Winget-AutoUpdate/ServiceUI.exe
# Zip WAU
zip -r WAU.zip Winget-AutoUpdate zip -r WAU.zip Winget-AutoUpdate
zip WAU.zip Winget-AutoUpdate-Install.ps1 zip WAU.zip Winget-AutoUpdate-Install.ps1
zip WAU.zip excluded_apps.txt zip WAU.zip excluded_apps.txt
zip WAU.zip install.bat zip WAU.zip install.bat
zip WAU.zip uninstall.bat zip WAU.zip uninstall.bat
# Zip ADMX
cd Policies cd Policies
zip -r ../WAU_ADMX.zip * zip -r ../WAU_ADMX.zip *
cd .. cd ..

View File

@ -17,7 +17,31 @@ $Script:IsSystem = [System.Security.Principal.WindowsIdentity]::GetCurrent().IsS
#Log initialisation #Log initialisation
$LogFile = "$WorkingDir\logs\updates.log" $LogFile = "$WorkingDir\logs\updates.log"
Write-ToLog -LogMsg "CHECK FOR APP UPDATES" -IsHeader
if ($IsSystem) {
#Check if any connected user when running as system
$explorerprocesses = @(Get-WmiObject -Query "Select * FROM Win32_Process WHERE Name='explorer.exe'" -ErrorAction SilentlyContinue)
#Check if ServiceUI exists
$ServiceUI = Test-Path "$WorkingDir\ServiceUI.exe"
If ($explorerprocesses.Count -gt 0 -and $ServiceUI) {
#User connected, Check for current session ID (O = system)
$SessionID = [System.Diagnostics.Process]::GetCurrentProcess().SessionId
if ($SessionID -eq 0) {
#Rerun WAU in system context with ServiceUI
& $WorkingDir\ServiceUI.exe -process:explorer.exe $env:windir\System32\wscript.exe \`"$WorkingDir\Invisible.vbs\`" \`"powershell.exe -NoProfile -ExecutionPolicy Bypass -File \`"\`"$WorkingDir\winget-upgrade.ps1\`"\`"\`"
Exit 0
}
else {
Write-ToLog -LogMsg "CHECK FOR APP UPDATES (System context with ServiceUI)" -IsHeader
}
}
else {
Write-ToLog -LogMsg "CHECK FOR APP UPDATES (System context)" -IsHeader
}
}
else {
Write-ToLog -LogMsg "CHECK FOR APP UPDATES (User context)" -IsHeader
}
#Get settings and Domain/Local Policies (GPO) if activated. #Get settings and Domain/Local Policies (GPO) if activated.
$Script:WAUConfig = Get-WAUConfig $Script:WAUConfig = Get-WAUConfig
@ -27,7 +51,6 @@ if ($($WAUConfig.WAU_ActivateGPOManagement -eq 1)) {
#Log running context and more... #Log running context and more...
if ($IsSystem) { if ($IsSystem) {
Write-ToLog "Running in System context"
# Maximum number of log files to keep. Default is 3. Setting MaxLogFiles to 0 will keep all log files. # Maximum number of log files to keep. Default is 3. Setting MaxLogFiles to 0 will keep all log files.
$MaxLogFiles = $WAUConfig.WAU_MaxLogFiles $MaxLogFiles = $WAUConfig.WAU_MaxLogFiles
@ -61,9 +84,6 @@ if ($IsSystem) {
$SettingsPath = "$Env:windir\system32\config\systemprofile\AppData\Local\Microsoft\WinGet\Settings\defaultState\settings.json" $SettingsPath = "$Env:windir\system32\config\systemprofile\AppData\Local\Microsoft\WinGet\Settings\defaultState\settings.json"
Add-ScopeMachine $SettingsPath Add-ScopeMachine $SettingsPath
} }
else {
Write-ToLog "Running in User context"
}
#Get Notif Locale function #Get Notif Locale function
$LocaleDisplayName = Get-NotifLocale $LocaleDisplayName = Get-NotifLocale

View File

@ -1,7 +1,7 @@
Function Confirm-Installation ($AppName, $AppVer){ Function Confirm-Installation ($AppName, $AppVer){
#Set json export file #Set json export file
$JsonFile = "$WorkingDir\Config\InstalledApps.json" $JsonFile = "$WorkingDir\InstalledApps.json"
#Get installed apps and version in json file #Get installed apps and version in json file
& $Winget export -s winget -o $JsonFile --include-versions | Out-Null & $Winget export -s winget -o $JsonFile --include-versions | Out-Null

View File

@ -197,6 +197,7 @@ function Invoke-PostUpdateActions {
Write-ToLog "-> Policies task created." Write-ToLog "-> Policies task created."
} }
### End of post update actions ### ### End of post update actions ###
#Reset WAU_UpdatePostActions Value #Reset WAU_UpdatePostActions Value

View File

@ -26,7 +26,7 @@ function Write-ToLog {
#If header requested #If header requested
if ($IsHeader) { if ($IsHeader) {
$Log = " `n##################################################`n# $LogMsg - $(Get-Date -Format (Get-culture).DateTimeFormat.ShortDatePattern)`n##################################################" $Log = " `n########################################################`n# $LogMsg - $(Get-Date -Format (Get-culture).DateTimeFormat.ShortDatePattern)`n########################################################"
} }
else { else {
$Log = "$(Get-Date -UFormat "%T") - $LogMsg" $Log = "$(Get-Date -UFormat "%T") - $LogMsg"