I would like to create an alias for finding process on specified port and an alias to kill process by PID.
-
Create an
alias.cmd
file in%USERPROFILE%
notepad alias.cmd
then add the following three lines to the file:
@echo off DOSKEY proc=netstat -ano ^| findstr :$1 DOSKEY kill=taskkill /F /PID $1
The first alias
proc
accepts one argument and lists PID of process running on that port.
The second -kill
(which also accepts one argument) - terminates the process by PID. Run regedit and go to
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor
(for MS10),HKEY_CURRENT_USER\Software\Microsoft\Command Processor
(for < MS10). AddString Value
entry with the nameAutoRun
and value%USERPROFILE%\alias.cmd
(path to .cmd file).
Now I can start cmd
, type proc 8080
and then for example kill 15003
.
Top comments (0)