# Get the Google Update folder path $googleUpdateFolder = "C:\Program Files (x86)\Google\GoogleUpdater" # Get all subfolders and extract version numbers $subfolders = Get-ChildItem $googleUpdateFolder | Where-Object { $_.PSIsContainer -and $_.BaseName -match '\d+\.\d+\.\d+\.\d+' } | ForEach-Object { [version]$_.BaseName } # Find the subfolder with the highest version number $latestSubfolder = $subfolders | Sort-Object -Descending | Select-Object -First 1 if ($latestSubfolder) { # Construct the full path to the updater.exe, ensuring proper quoting $updaterPath = Join-Path $googleUpdateFolder $latestSubfolder $updaterPath += "\updater.exe" $quotedUpdaterPath = '"' + $updaterPath + '"' # Create a new task with the updated path and a startup trigger $newTaskName = "Update_Chrome_" + (Get-Date -Format "yyyyMMddHHmmss") Register-ScheduledTask -TaskName $newTaskName -Action (New-ScheduledTaskAction -Execute $quotedUpdaterPath -Argument "--wake --system") -Trigger (New-JobTrigger -AtStartup) -Principal (New-ScheduledTaskPrincipal -UserId "SYSTEM" -RunLevel Highest) Write-Host "New task '$newTaskName' created with startup trigger and updated path: $quotedUpdaterPath" } else { Write-Host "Google Update folder or updater.exe not found." }