Using Environment variable in registry for command

Solution 1:

You should remember to make the registry value a REG_EXPAND_SZ instead of a REG_SZ. Normally, only REG_EXPAND_SZ values are expanded.

Solution 2:

Don't forget that %ProgramFiles(x86)% will expand with spaces in the name so the path(s) needs to be enclosed in quotes. It might work like: "%ProgramFiles(x86)%\Feliratozo\Feliratozo.exe" "%1" Also, Frank Thomas is correct about %ProgramFiles(x86)% not working on 32bit Windows.

Variables are expanded based on the parent process though. %ProgramFiles% will expand to C:\Program Files (x86) on a 64bit installation if you use the 32bit console or regedit (Located in SysWOW64).

A simple solution:

Install.cmd:

IF EXIST %WinDIR%\SysWOW64\regedit.exe (
   %WinDIR%\SysWOW64\regedit.exe /s Install.reg
) ELSE (
   %WinDIR%\regedit.exe /s Install.reg
)

Install.reg:

Windows Registry Editor Version 5.00

[...\shell\myThing\command]
@="\"%ProgramFiles%\\Feliratozo\\Feliratozo.exe\" \"%1\""