I have Windows Vista, but I guess this pertains to other versions as well. I want to set a program to be used in the Open With context menu. Now I want that the path to the .exe contain an environment variable. In that way, I can move the location of my app, change the corresponding environment variable, and everything works fine.
The problem has three components:
The value of the key in
HKEY_CLASSES_ROOT\Applications\myapp.exe\shell\open\command
e.g.,
"C:\myapp\myapp.exe" "%1"
, is hardcoded, and the type isREG_SZ
. I would need it to be of typeREG_EXPAND_SZ
, e.g.,"%MYAPPSDIR%\myapp.exe" "%1"
. This is typical for built-in programs, e.g.,%SystemRoot%\system32\NOTEPAD.EXE %1
.The type of key cannot be changed, so what was born as
REG_SZ
, so it lives.It appears that I cannot "regenerate" the variable as
REG_EXPAND_SZ
.
Is there any chance of doing what I mean?
There is also a bonus question, How to receive a parameter in a batch file.