【MindM】MM实用小技巧

# 定义要遍历的文件夹路径数组
$FolderPaths = @(
    "D:\softwares\Minjet2020",
    "D:\softwares\Minjet2020"
)

# 遍历每个文件夹路径
foreach ($FolderPath in $FolderPaths) {
    # 获取当前文件夹路径中的所有 .exe 文件
    $Files = Get-ChildItem -Path $FolderPath -Filter "*.exe" -Recurse

    # 遍历每个文件并创建防火墙规则
    foreach ($File in $Files) {
        $RuleName = "Block Internet - " + $File.Name
        New-NetFirewallRule -DisplayName $RuleName -Direction Outbound -Program $File.FullName -Action Block -Profile Any -Enabled True
    }
}




Get-Process | Where-Object {$_.ProcessName -like "*MmMess*"} | ForEach-Object { 
    $path = try { $_.MainModule.FileName } catch { "无法获取路径(可能需要管理员权限)" }
    Write-Host "正在终止进程: $($_.ProcessName) (PID: $($_.Id)) 路径: $path" 
    taskkill /F /PID $_.Id /T 
}



你可能感兴趣的:(java,服务器,前端)