或者将脚本保存为 disable-edge-auto-update.ps1 文件,右键点击 “使用 PowerShell 运行”
disable-edge-auto-update.ps1if ([Environment]::Is64BitOperatingSystem -eq "True") { $PF=${env:ProgramFiles(x86)} } else { $PF=$env:ProgramFiles }
if ($(Test-Path "$PF\Microsoft\Edge\Application\msedge.exe") -eq "True") { taskkill /im MicrosoftEdgeUpdate.exe /f taskkill /im msedge.exe /f Stop-Service -Name "edgeupdate" Stop-Service -Name "edgeupdatem" Stop-Service -Name "MicrosoftEdgeElevationService" sc.exe delete "edgeupdate" sc.exe delete "edgeupdatem" sc.exe delete "MicrosoftEdgeElevationService" Get-ScheduledTask -taskname MicrosoftEdgeUpdate* | Unregister-ScheduledTask -Confirm: $false Remove-Item "$PF\Microsoft\EdgeUpdate" -Recurse -Force Write-Output "Disable Microsoft Edge Enterprise Auto Update Successful!" } elseif ($(Test-Path "$env:USERPROFILE\AppData\Local\Microsoft\Edge\Application\msedge.exe") -eq "True") { taskkill /im MicrosoftEdgeUpdate.exe /f taskkill /im msedge.exe /f function Get-CurrentUserSID { [CmdletBinding()] param( ) Add-Type -AssemblyName System.DirectoryServices.AccountManagement return ([System.DirectoryServices.AccountManagement.UserPrincipal]::Current).SID.Value } schtasks.exe /Delete /TN \MicrosoftEdgeUpdateTaskUser$(Get-CurrentUserSID)Core /F schtasks.exe /Delete /TN \MicrosoftEdgeUpdateTaskUser$(Get-CurrentUserSID)UA /F Remove-Item "$env:USERPROFILE\AppData\Local\Microsoft\EdgeUpdate" -Recurse -Force Write-Output "Disable Microsoft Edge Users Setup Auto Update Successful!" } else { Write-Output "No Microsoft Edge Installation Detected!" }
|