Configuring a hotkey command using environment variables

I use opus on a stick , the same one, at work and home.
At work i use office 2016, at home, 2015
I have a hotkey that runs the following command

@nodeselect
@keydown:common
"C:\Program Files (x86)\Microsoft Office\"%OfficeVersion%"\OUTLOOK.EXE" /c ipm.note

I set an environment variable
OfficeVersion
on my work PC to contain
Office15
but the command didn't use it; how do I get that to occur ?

Have you tried "MS-DOS Batch function" for your button instead of "Standard Function (opus or external)" ?

If it is still not working you should test your environnement variables too in a console).
For example create a button as "MS-DOS Batch function" and add these lines.
set
echo "C:\Program Files (x86)\Microsoft Office"%OfficeVersion%"\OUTLOOK.EXE"
pause

and see how it is behaving.

image

Give this a try

@nodeselect
@keydown:common
{apppath|outlook.exe}outlook.exe /c ipm.note

The command in the first post is almost correct as it was, you just had two extra " that should not be there in the middle of the path.

Just use %variable_name% to insert a variable into a command. e.g. %OfficeVersion%. Don't put quotes around it, unless you actually want those quotes in the command. Quotes should go around the whole path, not around individual directories within the path.

You do not need to change the command type. Leave it as Standard Function (Opus or External).

This should work:

@nodeselect
"C:\Program Files (x86)\Microsoft Office\%OfficeVersion%\OUTLOOK.EXE" /c ipm.note

(I also removed @keydown:common as it it won't do anything on its own.)

Bow you also know how to insert environment variables into commands. But, at least for Outlook, Lxp's suggestion in the previous post, of using {apppath|outlook.exe}outlook.exe instead, may be even better here, as it saves you having to have the environment variable at all. That only works with programs that register where they are installed, which is not all of them.

Thx lxp, great tip, and Leo's extra-detail helps, too

Thx Leo for your speedy and comprehensive answer