Using FOR command to extract PID from TASKLIST
Put this in a .bat file, and you could use it like that:
BAT_FILE.bat <PROCESS_NAME> <COMMAND>
for /F "tokens=2,* delims=, " %%i IN ('tasklist ^| findstr %1') DO <MY_COMMAND> %%i %2
This is useful when writing an injector, and looking to inject to a specific process by its name, for example:
Replace MY_COMMAND with something like inject.exe, which will inject depending on a provided file path
BAT_FILE.bat notepad.exe my_library.dll