Skip to content

Latest commit

 

History

History
49 lines (33 loc) · 1.03 KB

06262022.md

File metadata and controls

49 lines (33 loc) · 1.03 KB
  1. 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>
  1. Searching for existence package in the yum repo list:
  • eg: All the packages started with phrase go
su -c 'yum list go\*'
  1. Extract specific field from output of tasklist in cmd:
wmic process where caption="python3.9.exe" get ProcessId
wmic logicaldisk (not really related)
  1. Redirect or assign a stdout to variable in cmd:
  • Solution 1:
echo dir /-D > test.txt
set /p something=<test.txt
echo %something%
  • Solution 2:
for /f "tokens=* USEBACKQ" %%i in ('tasklist ^| findstr "explorer"') do set VAR=%%i
  • NOTE:
  • 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.