You have to solve the problem, like with a pipe. ^|
Just open it until2^>NUL
So you get
for /f "tokens=2,*" %%a in ('reg query HKLM\Software\MySoftware\1.0\MyExecutable /v "InstallDir" 2^>NUL ^| findstr InstallDir') do set InstallPath=%%b
, FOR-Loop .
( 2 > NUL ), cmd.exe( 2 > NUL stderr reg)