1
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?
(1) Look at the Properties dialog for your picture shortcuts. Do they still have
%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 theset
likeecho %%MYPHOTOSDRIVE%%
to see if it is correct. (3) I don’t think IrfanView can take a shortcut; it won’t resolve automatically. – Synetech – 2012-02-06T01:08:01.050*1 Yes, all picture shortcuts have %MYPHOTOSDRIVE% instead of a drive letter. *2 Env. variable is set properly when I check it this way. *3 I was hoping that it would work the same as it does when calling another batch script from the first one. In this case this variable would be expanded to a proper value... – schedar – 2012-02-06T01:13:21.350