req query "HKEY_CURRENT_USER\Software\Stupid\MS" /v "installpath"
returns this on my xp (sorry I don't have anything more recent at the moment)
! REG.EXE VERSION 3.0
HKEY_CURRENT_USER\Software\Stupid\MS
installpath REG_SZ C:\Program Files (x86)\Stupid\MS
When using delim's default value (a space) what we actually need is the third and following tokens from the last line. "third and following" is tokens=3*
. The third token will be available in %%i, the "and following" in %%j. This letter is automatically assigned.
Unfortunately the first line also has a third and following token, so we need to exclude the first line. We can do that by using the eol option to exclude lines starting with "!". "Setlocal enabledelayedexpansion" doesn't change anything in this litte batch file so I dropped it.
Summary: this works for me:
@echo off
for /f "eol=! tokens=3*" %%i in ('reg query "HKEY_CURRENT_USER\Software\Conceptworld\Piky\Settings" /v "installpath"') do echo %%i %%j