
Windows ta cevap vermeyen herhangi bir uygulamayı kolayca sonlandırmak için sağ tuş menüsüne Kill not responding tasks (cevap vermeyen uygulamaları kapat ) kısayolu ekleyen registry kayıtları ektedir (vista ve Windows 7 içindir)










Kod: Tümünü seç
# Kill_Selected_Task_GUI.ps1
# Lists running processes (via tasklist) in a .NET Windows Forms window.
# The user selects a process from the list and terminates it with a button click.
# Compatible with Windows PowerShell 5.1 and PowerShell 7.x
$currentIdentity = [Security.Principal.WindowsIdentity]::GetCurrent()
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal($currentIdentity)
$isAdmin = $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
# Re-launch this same script elevated, then exit the non-elevated instance
$scriptPath = $MyInvocation.MyCommand.Path
Start-Process -FilePath "powershell.exe" -ArgumentList @(
"-NoProfile",
"-ExecutionPolicy", "Bypass",
"-WindowStyle", "Hidden",
"-File", "`"$scriptPath`""
) -Verb RunAs
exit
}
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
function Get-TaskListData {
# Use tasklist /FO CSV for clean parsing, then convert to objects
$raw = tasklist /FO CSV /NH
$items = @()
foreach ($line in $raw) {
if ([string]::IsNullOrWhiteSpace($line)) { continue }
$fields = $line -split '","'
$fields = $fields -replace '^"', '' -replace '"$', ''
if ($fields.Count -ge 5) {
$items += [PSCustomObject]@{
ImageName = $fields[0]
PID_ = $fields[1]
SessionName = $fields[2]
Session = $fields[3]
MemUsage = $fields[4]
}
}
}
return $items | Sort-Object ImageName
}
# ---- Build the form ----
$form = New-Object System.Windows.Forms.Form
$adminTag = if ($isAdmin) { "[Administrator]" } else { "[Standard User]" }
$form.Text = "Active Processes - Select One to Terminate $adminTag"
$form.Size = New-Object System.Drawing.Size(620, 520)
$form.StartPosition = "CenterScreen"
$form.MinimumSize = New-Object System.Drawing.Size(500, 400)
$form.Font = New-Object System.Drawing.Font("Segoe UI", 9)
$listView = New-Object System.Windows.Forms.ListView
$listView.View = [System.Windows.Forms.View]::Details
$listView.FullRowSelect = $true
$listView.GridLines = $true
$listView.MultiSelect = $false
$listView.Dock = [System.Windows.Forms.DockStyle]::Top
$listView.Height = 380
$listView.Columns.Add("Process Name", 220) | Out-Null
$listView.Columns.Add("PID", 80) | Out-Null
$listView.Columns.Add("Session", 100) | Out-Null
$listView.Columns.Add("Memory Usage", 130) | Out-Null
function Populate-List {
$listView.Items.Clear()
$tasks = Get-TaskListData
foreach ($t in $tasks) {
$row = New-Object System.Windows.Forms.ListViewItem($t.ImageName)
$row.SubItems.Add($t.PID_) | Out-Null
$row.SubItems.Add($t.SessionName) | Out-Null
$row.SubItems.Add($t.MemUsage) | Out-Null
$listView.Items.Add($row) | Out-Null
}
}
Populate-List
$lblManual = New-Object System.Windows.Forms.Label
$lblManual.Text = "Or type an .exe name manually:"
$lblManual.Location = New-Object System.Drawing.Point(10, 390)
$lblManual.Size = New-Object System.Drawing.Size(220, 20)
$txtManual = New-Object System.Windows.Forms.TextBox
$txtManual.Location = New-Object System.Drawing.Point(220, 388)
$txtManual.Size = New-Object System.Drawing.Size(200, 22)
$txtManual.PlaceholderText = "example.exe"
$btnRefresh = New-Object System.Windows.Forms.Button
$btnRefresh.Text = "Refresh"
$btnRefresh.Location = New-Object System.Drawing.Point(10, 420)
$btnRefresh.Size = New-Object System.Drawing.Size(100, 32)
$btnRefresh.Add_Click({ Populate-List })
$btnKill = New-Object System.Windows.Forms.Button
$btnKill.Text = "Terminate Selected"
$btnKill.Location = New-Object System.Drawing.Point(330, 420)
$btnKill.Size = New-Object System.Drawing.Size(140, 32)
$btnKill.BackColor = [System.Drawing.Color]::IndianRed
$btnKill.ForeColor = [System.Drawing.Color]::White
$btnClose = New-Object System.Windows.Forms.Button
$btnClose.Text = "Close"
$btnClose.Location = New-Object System.Drawing.Point(480, 420)
$btnClose.Size = New-Object System.Drawing.Size(110, 32)
$btnClose.Add_Click({ $form.Close() })
$btnKill.Add_Click({
$targetName = $null
if (-not [string]::IsNullOrWhiteSpace($txtManual.Text)) {
$targetName = $txtManual.Text.Trim()
}
elseif ($listView.SelectedItems.Count -gt 0) {
$targetName = $listView.SelectedItems[0].Text
}
if ([string]::IsNullOrWhiteSpace($targetName)) {
[System.Windows.Forms.MessageBox]::Show("Select a process from the list or type an .exe name.", "No selection", "OK", "Warning")
return
}
$confirm = [System.Windows.Forms.MessageBox]::Show(
"Terminate all processes named '$targetName'?",
"Confirm termination",
[System.Windows.Forms.MessageBoxButtons]::YesNo,
[System.Windows.Forms.MessageBoxIcon]::Question
)
if ($confirm -eq [System.Windows.Forms.DialogResult]::Yes) {
try {
$output = & taskkill /F /IM "$targetName" 2>&1
$exitCode = $LASTEXITCODE
$outputText = ($output | Out-String).Trim()
if ($exitCode -eq 0) {
[System.Windows.Forms.MessageBox]::Show("Terminated successfully:`n`n$outputText", "Done", "OK", "Information")
}
else {
[System.Windows.Forms.MessageBox]::Show("taskkill reported a problem (exit code $exitCode):`n`n$outputText`n`nIf the process needs elevated rights, re-run this script as Administrator.", "Not terminated", "OK", "Warning")
}
Populate-List
$txtManual.Clear()
}
catch {
[System.Windows.Forms.MessageBox]::Show("Error: $($_.Exception.Message)", "Failed", "OK", "Error")
}
}
})
$form.Controls.Add($listView)
$form.Controls.Add($lblManual)
$form.Controls.Add($txtManual)
$form.Controls.Add($btnRefresh)
$form.Controls.Add($btnKill)
$form.Controls.Add($btnClose)
[void]$form.ShowDialog()
Kod: Tümünü seç
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\DesktopBackground\Shell\KillSelectedTask]
@="Kill Selected Task..."
"Icon"="explorer.exe,9"
"Position"="Bottom"
[HKEY_CLASSES_ROOT\DesktopBackground\Shell\KillSelectedTask\command]
@="powershell.exe -NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -File \"C:\\Scripts\\Kill_Selected_Task_GUI.ps1\""




Kod: Tümünü seç
Windows Registry Editor Version 5.00
[-HKEY_CLASSES_ROOT\DesktopBackground\Shell\KillSelectedTask]