diff --git a/apps.cmd b/apps.cmd new file mode 100644 index 0000000..767b5fd --- /dev/null +++ b/apps.cmd @@ -0,0 +1,85 @@ +# 2>NUL & @CLS & PUSHD "%~dp0" & "%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -noLogo -noProfile -ExecutionPolicy bypass "[IO.File]::ReadAllText('%~f0')|iex" & POPD & EXIT /B + +# Check and install dependencies if needed +Write-Host "Controleer dependencies..." -ForegroundColor Yellow + +# Check if winget is available +try { + $wingetVersion = winget --version 2>$null + if ($wingetVersion) { + Write-Host "winget is beschikbaar: $wingetVersion" -ForegroundColor Green + } else { + throw "winget niet gevonden" + } +} catch { + Write-Host "winget niet gevonden. Probeer te installeren..." -ForegroundColor Red + + # Try to install winget from Microsoft Store + try { + Write-Host "Installeer winget via Microsoft Store..." -ForegroundColor Yellow + Start-Process "ms-windows-store://pdp/?ProductId=9NBLGGH4NNS1" -Wait + Write-Host "Controleer of winget nu beschikbaar is..." -ForegroundColor Yellow + + # Wait a bit and check again + Start-Sleep -Seconds 5 + $wingetVersion = winget --version 2>$null + if ($wingetVersion) { + Write-Host "winget succesvol geïnstalleerd: $wingetVersion" -ForegroundColor Green + } else { + throw "winget installatie mislukt" + } + } catch { + Write-Host "Automatische winget installatie mislukt. Probeer handmatig:" -ForegroundColor Red + Write-Host "1. Open Microsoft Store" -ForegroundColor White + Write-Host "2. Zoek naar 'App Installer'" -ForegroundColor White + Write-Host "3. Installeer de App Installer" -ForegroundColor White + Write-Host "4. Herstart PowerShell en voer dit script opnieuw uit" -ForegroundColor White + Read-Host "Druk op Enter om af te sluiten" + exit 1 + } +} + +# Check if running as administrator +$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") +if (-not $isAdmin) { + Write-Host "Dit script moet als Administrator worden uitgevoerd voor machine-wide installaties." -ForegroundColor Red + Write-Host "Start PowerShell opnieuw als Administrator en voer dit script opnieuw uit." -ForegroundColor Yellow + Read-Host "Druk op Enter om af te sluiten" + exit 1 +} + +Write-Host "Alle dependencies zijn beschikbaar. Start met app installaties..." -ForegroundColor Green +Write-Host "" + +# Install apps +$apps = @( + "Microsoft.DotNet.DesktopRuntime.8", + "Google.Chrome", + "Google.GoogleDrive", + "Google.ChromeRemoteDesktopHost", + "Dell.CommandUpdate", + "Logitech.OptionsPlus", + "Notepad++.Notepad++", + "Adobe.Acrobat.Reader.64-bit" +) + +$totalApps = $apps.Count +$currentApp = 0 + +foreach ($app in $apps) { + $currentApp++ + Write-Host "[$currentApp/$totalApps] Installeer $app..." -ForegroundColor Cyan + + try { + Start-Process -NoNewWindow -Wait -FilePath "winget" -ArgumentList "install --id $app -e --silent --accept-package-agreements --accept-source-agreements --source winget --scope machine" + Write-Host "✓ $app succesvol geïnstalleerd" -ForegroundColor Green + } catch { + Write-Host "✗ Fout bij installatie van $app" -ForegroundColor Red + Write-Host "Foutdetails: $($_.Exception.Message)" -ForegroundColor Red + } + + Write-Host "" +} + +Write-Host "App installatie voltooid!" -ForegroundColor Green +Read-Host "Druk op Enter om af te sluiten" \ No newline at end of file diff --git a/background.cmd b/background.cmd new file mode 100644 index 0000000..3c49f7f --- /dev/null +++ b/background.cmd @@ -0,0 +1,43 @@ +# 2>NUL & @CLS & PUSHD "%~dp0" & "%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -noLogo -noProfile -ExecutionPolicy bypass "[IO.File]::ReadAllText('%~f0')|iex" & POPD & EXIT /B + +# URL of the image +$imageUrl = "https://git.hibbit.net/HHO/Powershell/raw/commit/b23adb18f027f6e1d2e900e5563c79c07fe3567a/background/vincent-van-zalinge-v_IzolP4hGA-unsplash.jpg" + +# Create temp directory if it doesn't exist +$tempDir = "$env:TEMP\wallpaper" +if (-not (Test-Path $tempDir)) { + New-Item -ItemType Directory -Path $tempDir -Force | Out-Null +} + +# Download the image +$wallpaperPath = "$tempDir\background.jpg" +Write-Host "Downloading wallpaper..." -ForegroundColor Yellow +try { + Invoke-WebRequest -Uri $imageUrl -OutFile $wallpaperPath -TimeoutSec 60 + Write-Host "Download complete!" -ForegroundColor Green +} catch { + Write-Error "Failed to download wallpaper: $_" + exit 1 +} + +# Set the wallpaper +try { + $code = @' + using System.Runtime.InteropServices; + public class Wallpaper { + [DllImport("user32.dll", CharSet = CharSet.Auto)] + public static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni); + } +'@ + + Add-Type -TypeDefinition $code + $SPI_SETDESKWALLPAPER = 0x0014 + $SPIF_UPDATEINIFILE = 0x01 + $SPIF_SENDCHANGE = 0x02 + + [Wallpaper]::SystemParametersInfo($SPI_SETDESKWALLPAPER, 0, $wallpaperPath, $SPIF_UPDATEINIFILE -bor $SPIF_SENDCHANGE) + Write-Host "Wallpaper set successfully!" -ForegroundColor Green +} catch { + Write-Error "Failed to set wallpaper: $_" + exit 1 +} diff --git a/background/background.jpg b/background/background.jpg new file mode 100644 index 0000000..00117ac Binary files /dev/null and b/background/background.jpg differ diff --git a/background/background2.jpg b/background/background2.jpg new file mode 100644 index 0000000..9d6f4b1 Binary files /dev/null and b/background/background2.jpg differ diff --git a/background/vincent-van-zalinge-5Xp-MeScHpg-unsplash.jpg b/background/vincent-van-zalinge-5Xp-MeScHpg-unsplash.jpg new file mode 100644 index 0000000..c263df3 Binary files /dev/null and b/background/vincent-van-zalinge-5Xp-MeScHpg-unsplash.jpg differ diff --git a/background/vincent-van-zalinge-GgJYhuWwWgE-unsplash.jpg b/background/vincent-van-zalinge-GgJYhuWwWgE-unsplash.jpg new file mode 100644 index 0000000..92fe039 Binary files /dev/null and b/background/vincent-van-zalinge-GgJYhuWwWgE-unsplash.jpg differ diff --git a/background/vincent-van-zalinge-LtQ-BF3iAwI-unsplash.jpg b/background/vincent-van-zalinge-LtQ-BF3iAwI-unsplash.jpg new file mode 100644 index 0000000..ec8d69c Binary files /dev/null and b/background/vincent-van-zalinge-LtQ-BF3iAwI-unsplash.jpg differ diff --git a/background/vincent-van-zalinge-e5VzJJDODbQ-unsplash.jpg b/background/vincent-van-zalinge-e5VzJJDODbQ-unsplash.jpg new file mode 100644 index 0000000..d0d3539 Binary files /dev/null and b/background/vincent-van-zalinge-e5VzJJDODbQ-unsplash.jpg differ diff --git a/background/vincent-van-zalinge-r7aGQ0kifA0-unsplash.jpg b/background/vincent-van-zalinge-r7aGQ0kifA0-unsplash.jpg new file mode 100644 index 0000000..2959105 Binary files /dev/null and b/background/vincent-van-zalinge-r7aGQ0kifA0-unsplash.jpg differ diff --git a/background/vincent-van-zalinge-v_IzolP4hGA-unsplash.jpg b/background/vincent-van-zalinge-v_IzolP4hGA-unsplash.jpg new file mode 100644 index 0000000..00117ac Binary files /dev/null and b/background/vincent-van-zalinge-v_IzolP4hGA-unsplash.jpg differ diff --git a/get-serial.bat b/get-serial.bat new file mode 100644 index 0000000..d183022 --- /dev/null +++ b/get-serial.bat @@ -0,0 +1,40 @@ +@echo off +setlocal enabledelayedexpansion + +echo Retrieving laptop serial number... + +:: Gebruik de huidige map als uitvoerlocatie +set "output_dir=%~dp0" +:: Verwijder de backslash aan het einde +set "output_dir=!output_dir:~0,-1!" +echo Uitvoerlocatie: !output_dir! + +:: Get the serial number using PowerShell instead of WMIC +for /f "delims=" %%a in ('powershell -command "(Get-WmiObject -Class Win32_BIOS).SerialNumber"') do ( + set "serial=%%a" +) + +:: Remove any spaces from the serial number +set "serial=!serial: =!" + +:: Check if serial number was found +if "!serial!"=="" ( + echo Error: Could not retrieve serial number. + exit /b 1 +) + +:: Get the hostname +set "hostname=%COMPUTERNAME%" + +:: Create a text file with HOSTNAME_SERIAL as the filename +set "filename=!hostname!_!serial!.txt" +echo Serial Number: !serial! > "!output_dir!\!filename!" +echo Computer Name: !hostname! >> "!output_dir!\!filename!" +echo Date: %DATE% >> "!output_dir!\!filename!" +echo Time: %TIME% >> "!output_dir!\!filename!" + +echo Serial number !serial! has been saved to !output_dir!\!filename! +echo. +echo Script completed successfully. +pause +endlocal \ No newline at end of file diff --git a/update-all.cmd b/update-all.cmd new file mode 100644 index 0000000..a25a538 --- /dev/null +++ b/update-all.cmd @@ -0,0 +1,520 @@ +# 2>NUL & @CLS & PUSHD "%~dp0" & "%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -noLogo -noProfile -ExecutionPolicy bypass "[IO.File]::ReadAllText('%~f0')|iex" & POPD & EXIT /B + +# ============================================================================= +# COMPLETE SYSTEM UPDATE SCRIPT +# Dit script installeert en update alle applicaties, drivers en Windows updates +# ============================================================================= + +# Functie voor logging +function Write-Log { + param( + [string]$Message, + [string]$Level = "INFO" + ) + $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" + $logMessage = "[$timestamp] [$Level] $Message" + Write-Host $logMessage + + # Log ook naar bestand + try { + # Probeer verschillende methoden om het script pad te bepalen + $scriptPath = $null + + # Methode 1: Via $MyInvocation + if ($MyInvocation.ScriptName) { + $scriptPath = Split-Path -Parent $MyInvocation.ScriptName + } + + # Methode 2: Via $PSCommandPath + if (-not $scriptPath -and $PSCommandPath) { + $scriptPath = Split-Path -Parent $PSCommandPath + } + + # Methode 3: Via $PSScriptRoot + if (-not $scriptPath -and $PSScriptRoot) { + $scriptPath = $PSScriptRoot + } + + # Methode 4: Fallback naar huidige directory + if (-not $scriptPath) { + $scriptPath = Get-Location + } + + $logFile = Join-Path $scriptPath "update-log.txt" + Add-Content -Path $logFile -Value $logMessage -ErrorAction SilentlyContinue + } catch { + # Als alles faalt, probeer gewoon in de huidige directory + try { + Add-Content -Path "update-log.txt" -Value $logMessage -ErrorAction SilentlyContinue + } catch { + # Laatste fallback - geen logging naar bestand + } + } +} + +# Functie voor voortgangsindicator +function Show-Progress { + param( + [string]$Activity, + [string]$Status, + [int]$PercentComplete + ) + Write-Progress -Activity $Activity -Status $Status -PercentComplete $PercentComplete +} + +# Functie om te controleren of een commando bestaat +function Test-Command { + param([string]$Command) + try { + Get-Command $Command -ErrorAction Stop | Out-Null + return $true + } catch { + return $false + } +} + +# Functie om te wachten op gebruiker input +function Wait-ForUser { + param([string]$Message = "Druk op Enter om door te gaan...") + Write-Host $Message -ForegroundColor Yellow + Read-Host +} + +# ============================================================================= +# HOOFDSCRIPT START +# ============================================================================= + +Write-Host "================================================" -ForegroundColor Cyan +Write-Host " COMPLETE SYSTEM UPDATE SCRIPT" -ForegroundColor Cyan +Write-Host " Alle applicaties, drivers en Windows updates" -ForegroundColor Cyan +Write-Host "================================================" -ForegroundColor Cyan +Write-Host "" + +Write-Log "Script gestart" "INFO" + +# Controleer administrator rechten +$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") +if (-not $isAdmin) { + Write-Log "Script moet als Administrator worden uitgevoerd" "ERROR" + Write-Host "Dit script moet als Administrator worden uitgevoerd!" -ForegroundColor Red + Write-Host "Start PowerShell opnieuw als Administrator en voer dit script opnieuw uit." -ForegroundColor Yellow + Wait-ForUser + exit 1 +} + +Write-Log "Administrator rechten bevestigd" "INFO" + +# ============================================================================= +# STAP 1: DEPENDENCY CONTROLES +# ============================================================================= + +Write-Host "STAP 1: Controleer dependencies..." -ForegroundColor Green +Show-Progress -Activity "Dependency Controle" -Status "Controleer winget..." -PercentComplete 10 + +# Controleer winget +try { + $wingetVersion = winget --version 2>$null + if ($wingetVersion) { + Write-Log "winget is beschikbaar: $wingetVersion" "INFO" + Write-Host "✓ winget is beschikbaar: $wingetVersion" -ForegroundColor Green + } else { + throw "winget niet gevonden" + } +} catch { + Write-Log "winget niet gevonden, probeer te installeren" "WARNING" + Write-Host "⚠ winget niet gevonden. Probeer te installeren..." -ForegroundColor Yellow + + try { + Write-Host "Installeer winget via Microsoft Store..." -ForegroundColor Yellow + Start-Process "ms-windows-store://pdp/?ProductId=9NBLGGH4NNS1" -Wait -ErrorAction SilentlyContinue + Start-Sleep -Seconds 5 + + $wingetVersion = winget --version 2>$null + if ($wingetVersion) { + Write-Log "winget succesvol geïnstalleerd: $wingetVersion" "INFO" + Write-Host "✓ winget succesvol geïnstalleerd: $wingetVersion" -ForegroundColor Green + } else { + throw "winget installatie mislukt" + } + } catch { + Write-Log "winget installatie mislukt" "ERROR" + Write-Host "✗ Automatische winget installatie mislukt." -ForegroundColor Red + Write-Host "Probeer handmatig:" -ForegroundColor White + Write-Host "1. Open Microsoft Store" -ForegroundColor White + Write-Host "2. Zoek naar 'App Installer'" -ForegroundColor White + Write-Host "3. Installeer de App Installer" -ForegroundColor White + Wait-ForUser + exit 1 + } +} + +# Controleer Windows Update service +Show-Progress -Activity "Dependency Controle" -Status "Controleer Windows Update service..." -PercentComplete 20 +try { + $wuService = Get-Service -Name "wuauserv" -ErrorAction SilentlyContinue + if ($wuService -and $wuService.Status -ne "Running") { + Write-Log "Start Windows Update service" "INFO" + Start-Service -Name "wuauserv" -ErrorAction SilentlyContinue + Write-Host "✓ Windows Update service gestart" -ForegroundColor Green + } elseif ($wuService) { + Write-Host "✓ Windows Update service is actief" -ForegroundColor Green + } else { + Write-Host "⚠ Windows Update service niet beschikbaar" -ForegroundColor Yellow + } +} catch { + Write-Log "Windows Update service probleem" "WARNING" + Write-Host "⚠ Windows Update service probleem" -ForegroundColor Yellow +} + +# ============================================================================= +# STAP 2: WINDOWS UPDATES +# ============================================================================= + +Write-Host "" +Write-Host "STAP 2: Windows Updates..." -ForegroundColor Green +Show-Progress -Activity "Windows Updates" -Status "Controleer beschikbare updates..." -PercentComplete 30 + +try { + Write-Log "Start Windows Update controle" "INFO" + Write-Host "Controleer beschikbare Windows updates..." -ForegroundColor Cyan + + # Controleer updates + $updateSession = New-Object -ComObject Microsoft.Update.Session -ErrorAction SilentlyContinue + if ($updateSession) { + $updateSearcher = $updateSession.CreateUpdateSearcher() + $searchResult = $updateSearcher.Search("IsInstalled=0") + + if ($searchResult.Updates.Count -gt 0) { + Write-Host "✓ $($searchResult.Updates.Count) Windows updates gevonden" -ForegroundColor Green + Write-Log "Gevonden $($searchResult.Updates.Count) Windows updates" "INFO" + + # Toon details van elke update + Write-Host "Gevonden updates:" -ForegroundColor Cyan + for ($i = 0; $i -lt $searchResult.Updates.Count; $i++) { + $update = $searchResult.Updates.Item($i) + $updateNumber = $i + 1 + $kbNumber = "KB" + $update.KBArticleIDs.Item(0) + Write-Host "$updateNumber. $kbNumber - $($update.Title)" -ForegroundColor White + } + Write-Host "" + + # Download en installeer updates + Show-Progress -Activity "Windows Updates" -Status "Download en installeer updates..." -PercentComplete 40 + + $updatesToDownload = New-Object -ComObject Microsoft.Update.UpdateColl + foreach ($update in $searchResult.Updates) { + if ($update.IsDownloaded -eq $false) { + $updatesToDownload.Add($update) + } + } + + if ($updatesToDownload.Count -gt 0) { + Write-Host "Download $($updatesToDownload.Count) updates..." -ForegroundColor Cyan + $downloader = $updateSession.CreateUpdateDownloader() + $downloader.Updates = $updatesToDownload + $downloadResult = $downloader.Download() + + if ($downloadResult.ResultCode -eq 2) { + Write-Host "✓ Updates succesvol gedownload" -ForegroundColor Green + Write-Log "Windows updates gedownload" "INFO" + } else { + Write-Host "⚠ Download gedeeltelijk voltooid" -ForegroundColor Yellow + Write-Log "Windows updates gedeeltelijk gedownload" "WARNING" + } + } + + # Installeer updates + $updatesToInstall = New-Object -ComObject Microsoft.Update.UpdateColl + foreach ($update in $searchResult.Updates) { + if ($update.IsDownloaded -eq $true) { + $updatesToInstall.Add($update) + } + } + + if ($updatesToInstall.Count -gt 0) { + Write-Host "Installeer $($updatesToInstall.Count) updates..." -ForegroundColor Cyan + $installer = $updateSession.CreateUpdateInstaller() + $installer.Updates = $updatesToInstall + $installResult = $installer.Install() + + if ($installResult.ResultCode -eq 2) { + Write-Host "✓ Windows updates succesvol geïnstalleerd" -ForegroundColor Green + Write-Log "Windows updates geïnstalleerd" "INFO" + } else { + Write-Host "⚠ Installatie gedeeltelijk voltooid" -ForegroundColor Yellow + Write-Log "Windows updates gedeeltelijk geïnstalleerd" "WARNING" + } + } + } else { + Write-Host "✓ Geen Windows updates beschikbaar" -ForegroundColor Green + Write-Log "Geen Windows updates beschikbaar" "INFO" + } + } else { + Write-Host "⚠ Windows Update service niet beschikbaar" -ForegroundColor Yellow + Write-Log "Windows Update service niet beschikbaar" "WARNING" + } +} catch { + Write-Log "Windows Update fout" "ERROR" + Write-Host "✗ Fout bij Windows updates" -ForegroundColor Red +} + +# ============================================================================= +# STAP 3: DRIVER UPDATES +# ============================================================================= + +Write-Host "" +Write-Host "STAP 3: Driver Updates..." -ForegroundColor Green +Show-Progress -Activity "Driver Updates" -Status "Controleer driver updates..." -PercentComplete 50 + +# Dell Command Update (als beschikbaar) +if (Test-Command "DellCommandUpdate") { + try { + Write-Host "Controleer Dell driver updates..." -ForegroundColor Cyan + Write-Log "Start Dell Command Update" "INFO" + + # Voer Dell Command Update uit + $dellProcess = Start-Process -FilePath "DellCommandUpdate" -ArgumentList "/silent" -PassThru -Wait -ErrorAction SilentlyContinue + if ($dellProcess -and $dellProcess.ExitCode -eq 0) { + Write-Host "✓ Dell driver updates voltooid" -ForegroundColor Green + Write-Log "Dell driver updates voltooid" "INFO" + } else { + Write-Host "⚠ Dell driver updates gedeeltelijk voltooid" -ForegroundColor Yellow + Write-Log "Dell driver updates gedeeltelijk voltooid" "WARNING" + } + } catch { + Write-Log "Dell Command Update fout" "ERROR" + Write-Host "✗ Fout bij Dell driver updates" -ForegroundColor Red + } +} else { + Write-Host "⚠ Dell Command Update niet gevonden" -ForegroundColor Yellow + Write-Log "Dell Command Update niet beschikbaar" "WARNING" +} + +# Windows Driver Updates via winget +try { + Write-Host "Controleer Windows driver updates via winget..." -ForegroundColor Cyan + Show-Progress -Activity "Driver Updates" -Status "Update drivers via winget..." -PercentComplete 60 + + # Zoek naar driver updates + $driverUpdates = winget upgrade --source winget --include-unknown 2>$null | Select-String "driver|Driver" + + if ($driverUpdates) { + Write-Host "✓ Driver updates gevonden via winget" -ForegroundColor Green + Write-Log "Driver updates gevonden via winget" "INFO" + + # Installeer driver updates + winget upgrade --all --silent --accept-source-agreements --accept-package-agreements --include-unknown 2>$null + Write-Host "✓ Driver updates geïnstalleerd" -ForegroundColor Green + Write-Log "Driver updates geïnstalleerd via winget" "INFO" + } else { + Write-Host "✓ Geen driver updates beschikbaar via winget" -ForegroundColor Green + Write-Log "Geen driver updates beschikbaar via winget" "INFO" + } +} catch { + Write-Log "Driver update fout" "ERROR" + Write-Host "✗ Fout bij driver updates" -ForegroundColor Red +} + +# ============================================================================= +# STAP 4: APPLICATIE UPDATES +# ============================================================================= + +Write-Host "" +Write-Host "STAP 4: Applicatie Updates..." -ForegroundColor Green +Show-Progress -Activity "Applicatie Updates" -Status "Update alle applicaties..." -PercentComplete 70 + +try { + Write-Host "Controleer beschikbare applicatie updates..." -ForegroundColor Cyan + Write-Log "Start applicatie updates via winget" "INFO" + + # Controleer eerst welke updates beschikbaar zijn + Write-Host "Zoek naar beschikbare updates..." -ForegroundColor Yellow + $availableUpdates = winget upgrade --source winget --include-unknown 2>$null + + if ($availableUpdates -and $availableUpdates -match "No applicable updates found" -eq $false) { + # Parse de output om updates te vinden + $updateLines = $availableUpdates | Where-Object { $_ -match "^\w+\." -and $_ -notmatch "No applicable updates found" } + + if ($updateLines.Count -gt 0) { + Write-Host "✓ $($updateLines.Count) applicatie updates gevonden" -ForegroundColor Green + Write-Log "Gevonden $($updateLines.Count) applicatie updates" "INFO" + + # Toon details van elke update + Write-Host "Gevonden applicatie updates:" -ForegroundColor Cyan + $updateNumber = 1 + foreach ($line in $updateLines) { + if ($line -match "^\w+\.") { + # Parse de regel om app naam en versie te extraheren + $parts = $line -split "\s+" + if ($parts.Count -ge 3) { + $appName = $parts[0] + $currentVersion = $parts[1] + $newVersion = $parts[2] + Write-Host "$updateNumber. $appName ($currentVersion → $newVersion)" -ForegroundColor White + $updateNumber++ + } + } + } + Write-Host "" + } else { + Write-Host "✓ Geen applicatie updates beschikbaar" -ForegroundColor Green + Write-Log "Geen applicatie updates beschikbaar" "INFO" + } + } else { + Write-Host "✓ Geen applicatie updates beschikbaar" -ForegroundColor Green + Write-Log "Geen applicatie updates beschikbaar" "INFO" + } + + # Voer winget upgrade uit voor alle applicaties + Write-Host "Update alle applicaties via winget..." -ForegroundColor Cyan + $upgradeResult = winget upgrade --all --silent --accept-source-agreements --accept-package-agreements --include-unknown 2>$null + + if ($LASTEXITCODE -eq 0) { + Write-Host "✓ Alle applicaties succesvol geüpdatet" -ForegroundColor Green + Write-Log "Applicatie updates voltooid" "INFO" + } else { + Write-Host "⚠ Applicatie updates gedeeltelijk voltooid" -ForegroundColor Yellow + Write-Log "Applicatie updates gedeeltelijk voltooid" "WARNING" + } +} catch { + Write-Log "Applicatie update fout" "ERROR" + Write-Host "✗ Fout bij applicatie updates" -ForegroundColor Red +} + +# ============================================================================= +# STAP 5: OPTIONELE APPLICATIE INSTALLATIES +# ============================================================================= + +Write-Host "" +Write-Host "STAP 5: Optionele Applicatie Installaties..." -ForegroundColor Green +Show-Progress -Activity "Applicatie Installaties" -Status "Installeer essentiële applicaties..." -PercentComplete 80 + +# Lijst van essentiële applicaties +$essentialApps = @( + "Microsoft.DotNet.DesktopRuntime.8", + "Google.Chrome", + "Google.GoogleDrive", + "Google.ChromeRemoteDesktopHost", + "Dell.CommandUpdate", + "Logitech.OptionsPlus", + "Notepad++.Notepad++" +) + +$totalApps = $essentialApps.Count +$currentApp = 0 + +foreach ($app in $essentialApps) { + $currentApp++ + $percentComplete = 80 + (($currentApp / $totalApps) * 15) + Show-Progress -Activity "Applicatie Installaties" -Status "Installeer $app..." -PercentComplete $percentComplete + + Write-Host "[$currentApp/$totalApps] Controleer $app..." -ForegroundColor Cyan + + try { + # Controleer of app al geïnstalleerd is + $installed = winget list --id $app --exact 2>$null + + if (-not $installed -or $installed -match "No installed package found") { + Write-Host "Installeer $app..." -ForegroundColor Yellow + winget install --id $app -e --silent --accept-package-agreements --accept-source-agreements --source winget --scope machine 2>$null + Write-Host "✓ $app succesvol geïnstalleerd" -ForegroundColor Green + Write-Log "Applicatie geïnstalleerd: $app" "INFO" + } else { + Write-Host "✓ $app is al geïnstalleerd" -ForegroundColor Green + } + } catch { + Write-Host "✗ Fout bij installatie van $app" -ForegroundColor Red + Write-Log "Fout bij installatie van $app" "ERROR" + } +} + +# ============================================================================= +# STAP 6: SYSTEEM OPTIMALISATIE +# ============================================================================= + +Write-Host "" +Write-Host "STAP 6: Systeem Optimalisatie..." -ForegroundColor Green +Show-Progress -Activity "Systeem Optimalisatie" -Status "Voer systeem optimalisatie uit..." -PercentComplete 95 + +try { + Write-Host "Voer systeem optimalisatie uit..." -ForegroundColor Cyan + Write-Log "Start systeem optimalisatie" "INFO" + + # Schoon Windows Update cache + Write-Host "Schoon Windows Update cache..." -ForegroundColor Yellow + Stop-Service -Name "wuauserv" -Force -ErrorAction SilentlyContinue + Remove-Item -Path "$env:SystemRoot\SoftwareDistribution\Download\*" -Recurse -Force -ErrorAction SilentlyContinue + Start-Service -Name "wuauserv" -ErrorAction SilentlyContinue + Write-Host "✓ Windows Update cache opgeschoond" -ForegroundColor Green + + # Schoon temp bestanden + Write-Host "Schoon temp bestanden..." -ForegroundColor Yellow + Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction SilentlyContinue | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue + Write-Host "✓ Temp bestanden opgeschoond" -ForegroundColor Green + + # Voer DISM health check uit + Write-Host "Voer DISM health check uit..." -ForegroundColor Yellow + DISM /Online /Cleanup-Image /CheckHealth /NoRestart 2>$null | Out-Null + DISM /Online /Cleanup-Image /ScanHealth /NoRestart 2>$null | Out-Null + Write-Host "✓ DISM health check voltooid" -ForegroundColor Green + + Write-Log "Systeem optimalisatie voltooid" "INFO" +} catch { + Write-Log "Systeem optimalisatie fout" "ERROR" + Write-Host "✗ Fout bij systeem optimalisatie" -ForegroundColor Red +} + +# ============================================================================= +# VOLTOOIING +# ============================================================================= + +Show-Progress -Activity "Update Proces" -Status "Voltooid!" -PercentComplete 100 + +Write-Host "" +Write-Host "================================================" -ForegroundColor Green +Write-Host " UPDATE PROCES VOLTOOID!" -ForegroundColor Green +Write-Host "================================================" -ForegroundColor Green +Write-Host "" + +Write-Log "Update proces voltooid" "INFO" + +Write-Host "Samenvatting:" -ForegroundColor Cyan +Write-Host "✓ Windows Updates gecontroleerd en geïnstalleerd" -ForegroundColor Green +Write-Host "✓ Driver Updates gecontroleerd en geïnstalleerd" -ForegroundColor Green +Write-Host "✓ Applicatie Updates uitgevoerd" -ForegroundColor Green +Write-Host "✓ Essentiële applicaties geïnstalleerd" -ForegroundColor Green +Write-Host "✓ Systeem optimalisatie uitgevoerd" -ForegroundColor Green +Write-Host "" + +# Bepaal log bestand locatie +$logPath = "update-log.txt" +try { + if ($MyInvocation.ScriptName) { + $scriptPath = Split-Path -Parent $MyInvocation.ScriptName + $logPath = Join-Path $scriptPath "update-log.txt" + } elseif ($PSCommandPath) { + $scriptPath = Split-Path -Parent $PSCommandPath + $logPath = Join-Path $scriptPath "update-log.txt" + } elseif ($PSScriptRoot) { + $logPath = Join-Path $PSScriptRoot "update-log.txt" + } +} catch { + # Fallback naar huidige directory +} + +Write-Host "Log bestand opgeslagen in: $logPath" -ForegroundColor Yellow +Write-Host "" + +# Vraag of gebruiker wil herstarten +$restart = Read-Host "Wil je de computer nu herstarten? (j/n)" +if ($restart -eq "j" -or $restart -eq "J" -or $restart -eq "y" -or $restart -eq "Y") { + Write-Host "Computer wordt herstart in 10 seconden..." -ForegroundColor Yellow + Write-Log "Computer herstart gepland" "INFO" + Start-Sleep -Seconds 10 + Restart-Computer -Force +} else { + Write-Host "Herstart later handmatig om alle updates volledig toe te passen." -ForegroundColor Yellow + Wait-ForUser +} + +Write-Log "Script beëindigd" "INFO" diff --git a/update-apps.cmd b/update-apps.cmd new file mode 100644 index 0000000..6095c47 --- /dev/null +++ b/update-apps.cmd @@ -0,0 +1,27 @@ +@echo off +:: Controleer op administrator rechten +net session >nul 2>&1 +if %errorlevel% neq 0 ( + echo Administrator rechten zijn vereist. Start het script opnieuw als administrator. + pause + exit /b 1 +) + +echo Starting application updates... +echo. + +:: Controleer of Winget is geïnstalleerd +where winget >nul 2>nul +if %errorlevel% neq 0 ( + echo Winget is niet geïnstalleerd. Installeer eerst de App Installer vanuit de Microsoft Store. + pause + exit /b 1 +) + +:: Voer winget upgrade uit voor alle applicaties +winget upgrade --all --silent --accept-source-agreements --accept-package-agreements --include-unknown + +echo. +echo Update proces is voltooid. +echo Druk op een toets om af te sluiten... +pause >nul \ No newline at end of file