Initial qiwei secondary development handoff
This commit is contained in:
210
disable_wxwork_update_client.ps1
Normal file
210
disable_wxwork_update_client.ps1
Normal file
@@ -0,0 +1,210 @@
|
||||
# ========================================
|
||||
# 企业微信更新禁用脚本 - 客户版
|
||||
# 用途:阻止企业微信自动更新
|
||||
# 使用方法:右键此文件 -> 以管理员身份运行
|
||||
# ========================================
|
||||
|
||||
$ErrorActionPreference = "Continue"
|
||||
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host "企业微信更新禁用工具" -ForegroundColor Cyan
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# 检查管理员权限
|
||||
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 "错误:需要管理员权限!" -ForegroundColor Red
|
||||
Write-Host "请右键此脚本,选择'以管理员身份运行'" -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
pause
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "✓ 已获取管理员权限" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
|
||||
# ========================================
|
||||
# 1. 禁用更新服务
|
||||
# ========================================
|
||||
Write-Host "[1/4] 正在禁用更新服务..." -ForegroundColor Yellow
|
||||
|
||||
$services = @(
|
||||
"WXWorkUpgrader",
|
||||
"WemeetUpdateSvc"
|
||||
)
|
||||
|
||||
$serviceCount = 0
|
||||
foreach ($serviceName in $services) {
|
||||
$service = Get-Service -Name $serviceName -ErrorAction SilentlyContinue
|
||||
if ($service) {
|
||||
try {
|
||||
if ($service.Status -ne "Stopped") {
|
||||
Stop-Service -Name $serviceName -Force -ErrorAction Stop
|
||||
Write-Host " ✓ 已停止服务: $serviceName" -ForegroundColor Green
|
||||
}
|
||||
Set-Service -Name $serviceName -StartupType Disabled -ErrorAction Stop
|
||||
Write-Host " ✓ 已禁用服务: $serviceName" -ForegroundColor Green
|
||||
$serviceCount++
|
||||
} catch {
|
||||
Write-Host " ✗ 无法处理服务: $serviceName - $($_.Exception.Message)" -ForegroundColor Red
|
||||
}
|
||||
} else {
|
||||
Write-Host " - 未找到服务: $serviceName" -ForegroundColor Gray
|
||||
}
|
||||
}
|
||||
|
||||
if ($serviceCount -eq 0) {
|
||||
Write-Host " 未找到任何更新服务" -ForegroundColor Gray
|
||||
}
|
||||
Write-Host ""
|
||||
|
||||
# ========================================
|
||||
# 2. 重命名更新程序
|
||||
# ========================================
|
||||
Write-Host "[2/4] 正在禁用更新程序..." -ForegroundColor Yellow
|
||||
|
||||
$wxworkPaths = @(
|
||||
"C:\Program Files (x86)\WXWork",
|
||||
"C:\Program Files\WXWork"
|
||||
)
|
||||
|
||||
$renamedCount = 0
|
||||
foreach ($basePath in $wxworkPaths) {
|
||||
if (Test-Path -Path $basePath) {
|
||||
Write-Host " 正在扫描: $basePath" -ForegroundColor Gray
|
||||
|
||||
$updaterFiles = Get-ChildItem -Path $basePath -Recurse -File -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.Name -match "^(WXWorkUpgrader|WemeetUpdateSvc|DeltaUpgradeHelper)\.exe$" }
|
||||
|
||||
foreach ($file in $updaterFiles) {
|
||||
$disabledPath = "$($file.FullName).disabled"
|
||||
try {
|
||||
if (-not (Test-Path -LiteralPath $disabledPath)) {
|
||||
Rename-Item -LiteralPath $file.FullName -NewName "$($file.Name).disabled" -Force -ErrorAction Stop
|
||||
Write-Host " ✓ 已重命名: $($file.Name)" -ForegroundColor Green
|
||||
$renamedCount++
|
||||
} else {
|
||||
Write-Host " - 已存在备份: $($file.Name).disabled" -ForegroundColor Gray
|
||||
}
|
||||
} catch {
|
||||
Write-Host " ✗ 无法重命名: $($file.Name) - $($_.Exception.Message)" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($renamedCount -eq 0) {
|
||||
Write-Host " 未找到需要重命名的更新程序" -ForegroundColor Gray
|
||||
}
|
||||
Write-Host ""
|
||||
|
||||
# ========================================
|
||||
# 3. 添加防火墙规则
|
||||
# ========================================
|
||||
Write-Host "[3/4] 正在添加防火墙阻止规则..." -ForegroundColor Yellow
|
||||
|
||||
$firewallCount = 0
|
||||
$updaterPatterns = @("WXWorkUpgrader.exe", "WemeetUpdateSvc.exe", "DeltaUpgradeHelper.exe")
|
||||
|
||||
foreach ($basePath in $wxworkPaths) {
|
||||
if (Test-Path -Path $basePath) {
|
||||
$updaterFiles = Get-ChildItem -Path $basePath -Recurse -File -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.Name -match "^(WXWorkUpgrader|WemeetUpdateSvc|DeltaUpgradeHelper)\.exe" }
|
||||
|
||||
foreach ($file in $updaterFiles) {
|
||||
$ruleName = "阻止企业微信更新 - $($file.Name)"
|
||||
|
||||
if (-not (Get-NetFirewallRule -DisplayName $ruleName -ErrorAction SilentlyContinue)) {
|
||||
try {
|
||||
New-NetFirewallRule -DisplayName $ruleName -Direction Outbound -Program $file.FullName -Action Block -Profile Any -ErrorAction Stop | Out-Null
|
||||
Write-Host " ✓ 已添加防火墙规则: $($file.Name)" -ForegroundColor Green
|
||||
$firewallCount++
|
||||
} catch {
|
||||
Write-Host " ✗ 无法添加防火墙规则: $($file.Name)" -ForegroundColor Red
|
||||
}
|
||||
} else {
|
||||
Write-Host " - 防火墙规则已存在: $($file.Name)" -ForegroundColor Gray
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($firewallCount -eq 0) {
|
||||
Write-Host " 未添加新的防火墙规则" -ForegroundColor Gray
|
||||
}
|
||||
Write-Host ""
|
||||
|
||||
# ========================================
|
||||
# 4. 禁用计划任务
|
||||
# ========================================
|
||||
Write-Host "[4/4] 正在禁用相关计划任务..." -ForegroundColor Yellow
|
||||
|
||||
$taskCount = 0
|
||||
$tasks = Get-ScheduledTask -ErrorAction SilentlyContinue |
|
||||
Where-Object {
|
||||
$_.TaskName -match "WXWork|Wemeet|WeMeet|Tencent" -or
|
||||
$_.TaskPath -match "WXWork|Wemeet|WeMeet|Tencent"
|
||||
}
|
||||
|
||||
foreach ($task in $tasks) {
|
||||
try {
|
||||
Disable-ScheduledTask -TaskName $task.TaskName -TaskPath $task.TaskPath -ErrorAction Stop | Out-Null
|
||||
Write-Host " ✓ 已禁用计划任务: $($task.TaskName)" -ForegroundColor Green
|
||||
$taskCount++
|
||||
} catch {
|
||||
Write-Host " ✗ 无法禁用计划任务: $($task.TaskName)" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
|
||||
if ($taskCount -eq 0) {
|
||||
Write-Host " 未找到需要禁用的计划任务" -ForegroundColor Gray
|
||||
}
|
||||
Write-Host ""
|
||||
|
||||
# ========================================
|
||||
# 显示当前状态
|
||||
# ========================================
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host "执行完成!当前状态:" -ForegroundColor Cyan
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
Write-Host "--- 服务状态 ---" -ForegroundColor Yellow
|
||||
$serviceStatus = Get-Service -Name WXWorkUpgrader,WemeetUpdateSvc -ErrorAction SilentlyContinue
|
||||
if ($serviceStatus) {
|
||||
$serviceStatus | Select-Object Name, Status, StartType | Format-Table -AutoSize
|
||||
} else {
|
||||
Write-Host "未找到更新服务" -ForegroundColor Gray
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "--- 更新程序文件 ---" -ForegroundColor Yellow
|
||||
$allFiles = @()
|
||||
foreach ($basePath in $wxworkPaths) {
|
||||
if (Test-Path -Path $basePath) {
|
||||
$files = Get-ChildItem -Path $basePath -Recurse -File -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.Name -match "(WXWorkUpgrader|WemeetUpdateSvc|DeltaUpgradeHelper)" } |
|
||||
Select-Object -First 10
|
||||
$allFiles += $files
|
||||
}
|
||||
}
|
||||
|
||||
if ($allFiles.Count -gt 0) {
|
||||
$allFiles | Select-Object Name, Length, LastWriteTime | Format-Table -AutoSize
|
||||
} else {
|
||||
Write-Host "未找到更新程序文件(可能已被重命名)" -ForegroundColor Gray
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host "操作完成!企业微信更新已被限制。" -ForegroundColor Green
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
pause
|
||||
Reference in New Issue
Block a user