Initial qiwei secondary development handoff
This commit is contained in:
79
tools/disable_wxwork_update.ps1
Normal file
79
tools/disable_wxwork_update.ps1
Normal file
@@ -0,0 +1,79 @@
|
||||
$ErrorActionPreference = "Continue"
|
||||
|
||||
function Test-Admin {
|
||||
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
|
||||
$principal = New-Object Security.Principal.WindowsPrincipal($identity)
|
||||
return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
||||
}
|
||||
|
||||
if (-not (Test-Admin)) {
|
||||
Write-Host "Please run this script as Administrator." -ForegroundColor Yellow
|
||||
pause
|
||||
exit 1
|
||||
}
|
||||
|
||||
$services = @(
|
||||
"WXWorkUpgrader",
|
||||
"WemeetUpdateSvc"
|
||||
)
|
||||
|
||||
foreach ($serviceName in $services) {
|
||||
$service = Get-Service -Name $serviceName -ErrorAction SilentlyContinue
|
||||
if ($service) {
|
||||
if ($service.Status -ne "Stopped") {
|
||||
Stop-Service -Name $serviceName -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
Set-Service -Name $serviceName -StartupType Disabled -ErrorAction SilentlyContinue
|
||||
Write-Host "Disabled service: $serviceName"
|
||||
}
|
||||
}
|
||||
|
||||
$updaters = @(
|
||||
"C:\Program Files (x86)\WXWork\WXWorkUpgrader\WXWorkUpgrader.exe",
|
||||
"C:\Program Files (x86)\WXWork\4.1.33.6009\WXWorkUpgrader.exe",
|
||||
"C:\Program Files (x86)\WXWork\4.1.33.6009\WeMeet\3.26.16.708\WemeetUpdateSvc.exe",
|
||||
"C:\Program Files (x86)\WXWork\4.1.33.6009\WeMeet\3.26.16.708\DeltaUpgradeHelper.exe"
|
||||
)
|
||||
|
||||
foreach ($path in $updaters) {
|
||||
if (Test-Path -LiteralPath $path) {
|
||||
$disabledPath = "$path.disabled"
|
||||
if (-not (Test-Path -LiteralPath $disabledPath)) {
|
||||
Rename-Item -LiteralPath $path -NewName ([IO.Path]::GetFileName($disabledPath)) -Force
|
||||
Write-Host "Renamed updater: $path"
|
||||
} else {
|
||||
Write-Host "Disabled backup already exists: $disabledPath"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($path in $updaters) {
|
||||
$ruleName = "Block WXWork updater - " + ([IO.Path]::GetFileName($path))
|
||||
if (-not (Get-NetFirewallRule -DisplayName $ruleName -ErrorAction SilentlyContinue)) {
|
||||
New-NetFirewallRule -DisplayName $ruleName -Direction Outbound -Program $path -Action Block -Profile Any | Out-Null
|
||||
Write-Host "Added firewall block rule: $ruleName"
|
||||
}
|
||||
}
|
||||
|
||||
Get-ScheduledTask -ErrorAction SilentlyContinue |
|
||||
Where-Object {
|
||||
$_.TaskName -match "WXWork|Wemeet|WeMeet|Tencent" -or
|
||||
$_.TaskPath -match "WXWork|Wemeet|WeMeet|Tencent"
|
||||
} |
|
||||
ForEach-Object {
|
||||
Disable-ScheduledTask -TaskName $_.TaskName -TaskPath $_.TaskPath -ErrorAction SilentlyContinue | Out-Null
|
||||
Write-Host "Disabled scheduled task: $($_.TaskPath)$($_.TaskName)"
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Done. Current updater status:" -ForegroundColor Green
|
||||
Get-Service -Name WXWorkUpgrader,WemeetUpdateSvc -ErrorAction SilentlyContinue |
|
||||
Select-Object Name,DisplayName,Status,StartType |
|
||||
Format-Table -AutoSize
|
||||
|
||||
Get-ChildItem -LiteralPath "C:\Program Files (x86)\WXWork" -Recurse -File -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.Name -match "WXWorkUpgrader|WemeetUpdateSvc|DeltaUpgradeHelper" } |
|
||||
Select-Object FullName,Length,LastWriteTime |
|
||||
Format-Table -AutoSize
|
||||
|
||||
pause
|
||||
Reference in New Issue
Block a user