I am trying to write a command to a file so that it can be run in the future.
How do I write the line netstat -ano | findstr :25565 >pid.txt
to the file stop.bat
?
Code:
echo @echo off> stop.bat
echo netstat -ano | findstr :25565 >pid.txt>> stop.bat
echo FOR /F "usebackq tokens=5" %%%%A in (pid.txt) do (>> stop.bat
echo taskkill /F /PID %%%%A>> stop.bat
echo exit /b>> stop.bat
echo )>> stop.bat
Output in file "stop.bat":
@echo off
FOR /F "usebackq tokens=5" %%A in (pid.txt) do (
taskkill /F /PID %%A
exit /b
)