I would like to create an alias for finding process on specified port and an alias to kill process by PID.
-
Create an
alias.cmdfile in%USERPROFILE%
notepad alias.cmdthen add the following three lines to the file:
@echo off DOSKEY proc=netstat -ano ^| findstr :$1 DOSKEY kill=taskkill /F /PID $1The first alias
procaccepts 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 Valueentry with the nameAutoRunand 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)