Tell me, please, why the team
sc query type= service | find /c "SERVICE_NAME: MySQL" sc query type= service | find /c "SERVICE_NAME: MySQL" returns, as expected, 1, and the command
FOR /F %g IN ('sc query type= service ^| find /c "SERVICE_NAME: MySQL"') do echo %g returns 0.
While the team
FOR /F %g IN ('net start ^| find /c "MySQL"') do echo %g again, as expected, returns 1. What is wrong with the second command?

    0