- Kill a specific process in Windows Server:
- Searching for the PID (process ID) that has been occupied by classifying through a port number:
netstat -aon | findstr <port>
- Then kill it with
taskkill
command:
taskkill /F /T /PID <pid>
- Searching for existence package in the
yum
repo list:
- eg: All the packages started with phrase
go
- Extract specific field from output of
tasklist
in cmd
:
wmic process where caption="python3.9.exe" get ProcessId
wmic logicaldisk (not really related)
- Redirect or assign a
stdout
to variable in cmd
:
echo dir /-D > test.txt
set /p something=<test.txt
echo %something%
for /f "tokens=* USEBACKQ" %%i in ('tasklist ^| findstr "explorer"') do set VAR=%%i
- The
%%i
with the first %
is used to escape the second one.
- Use USEBACKQ if you have a string to insert or a long file name, you can use your double quotes without screwing up the command.