@OpossumPetya said in Finding out install location - could you try on cmd?:
C:\>for /f "tokens=2 delims=REG_SZ" %i in ('reg query HKLM\SOFTWARE\Notepad++ ^| findstr /i /l /c:"Default"') do @echo %i 2> NUL
C:\Program Files\Notepad++
C:\>
delims operates on characters, not words so a path that contains any character of R, E, G, _, S, Z will echo a incomplete path. For example in a batch file:
for /f "tokens=2 delims=REG_SZ" %%A in (
'echo (Default^) REG_SZ C:\Program Files\rReEgG__sSzZ'
) do (
echo %%A
)
echoes C:\Program Files\r as R is a delimiter and e is the next token.
This is what I have tried so far to echo both x86 and x64 install paths of Notepad++
setlocal
if defined ProgramW6432 (
set "bit=/reg:32 /reg:64"
) else (
set bit=""
)
for %%Z in (%bit%) do (
for /f "tokens=1,2,*" %%A in (
'2^>nul reg query HKLM\Software\Notepad++ /ve %%~Z'
) do if "%%~A" == "(Default)" if "%%~B" == "REG_SZ" (
if not "%%~C" == "(value not set)" (
echo "%%~Z" "%%~C"
)
)
)
It also echoes the bit arg to let you know where the data came from. The bit arg will be empty if ProgramW6432 is not defined. I cannot specify if the bit arg is valid on Windows Vista or XP as no records available and do not have a VM for those OSes setup currently to test.