How can I make my environment variable (set in batch file) visible in application executed right after setting this envvar?
Here's the scenario that I use:
In my external script (not quite important here) I create Windows shortcuts to jpg files, with the target looking like:
%MYPHOTOSDRIVE%:\private\photos\photo001.jpg%MYPHOTODRIVE% should contain just a current drive letter.
I start IrfanView using the following BAT script (script is located in the same directory as all the .lnk files):
set MYPHOTOSDRIVE=%cd:~0,2% "c:\Program Files\IrfanView\i_view32.exe" "i:\private\photolinks\photo001.lnk" "c:\Program Files\IrfanView\i_view32.exe" /slideshow="%cd%"
The problem is that neither the single image, nor a slideshow (for the second call to IrfanView) is executed properly.
Shouldn't this "MYPHOTODRIVE" variable be expanded to a proper value upon Irfan execution? Doesn't it get the same environment as the parent script?

%MYPHOTOSDRIVE%? If that variable is not set globally (for all of Windows, not just a single console instance), then Explorer does not use it. (2) Try adding a line after thesetlikeecho %%MYPHOTOSDRIVE%%to see if it is correct. (3) I don’t think IrfanView can take a shortcut; it won’t resolve automatically. – Synetech Feb 6 at 1:08