Search notes:

kil.ps1

kil.ps1 is a PowerShell script to kill processes by their name. It might be called like so:
PS C:\> kil excel
The script can be given the -restart (or -r) argument to restart the process. If multiple processes were killed, only one process is restarted:
PS C:\> kil -r outlook

Source code

#
#   This script is called kil because kill is a default
#   alias for stop-process.
#

param (
  [switch] $restart
)

set-strictMode -version latest

if ( $args.count -lt 1 ) {
   write-host 'kil procName'
   return
}

$procName = $args[0]

# write-host $procName

$procs = get-process $procName -ea silentlyContinue

if ($procs -eq $null) {
   write-host 'no processes found'
   return
}

foreach ($proc in $procs) {
   write-host "Killing $proc"
   $procPath = $proc.path
   stop-process $proc
}

if ($restart) {
   start-process $procPath
}
Github repository scripts-and-utilities, path: /kil.ps1

See also

kill-procs.pl is a similar Perl script.
Terminating Windows processes.
Scripts

Index