set TEMP_FILE=mysqlpath.txt sc qc mysql | find /i "BINARY_PATH_NAME" > %TEMP_FILE% for /f "tokens=3 delims= " %%i in (%TEMP_FILE%) do set MYSQLD_PATH=%%i del /s /q %TEMP_FILE% echo %MYSQLD_PATH%