Unsolved

This post is more than 5 years old

3 Posts

11028

December 22nd, 2006 16:00

Windows Shortcuts: Dynamic Evaluation of the Target Parameter

Does anyone know how to specify the drive letter in a path so that maybe referenced symbolically as the current drive with the "target" of a Windows shortcut (WinXP, Win2K, ...)? The problem occurs when you include a short cut that references a file (executable, image, ...) and Windows includes the full path name; e.g.,
                D:\MyDir\jack.exe "D:\anotherDir\jill.jpg"
In both paths "D:" is hard coded but if you move the device (e.g. thumb drive) and on a second computer the correct paths would be 
           F:\MyDir\jack.exe "F:\anotherDir\jill.jpg"

What I would like to do is edit and replace "D:" with the %CurrentDrive%:; e.g.
       %CurrentDrive%:\MyDir\jack.exe  %CurrentDrive%:\AnotherDir\jill.jpg
or whatever the correct symbolic reference would be.  Note:
       %CWD% or %CW% 
is the reference to the Current Working Directory in the Command Prompt interface and
        %CW:~0,2%
returns the drive letter and colon, but apparenty the Win OS does not evaluate the parameters of the "target" at execution time (when you click on the shortcut) and  "D:\%CW%\ ... " is passed on (and you cannot use "!" in lieu of "%" for deferred evaluation.) Also, you cannot use path relative expressions -- "." (current directory) or "..\" (parent directory).  It appears that the only time the target of a shortcut is evaluated when it is edited and thereafter the parameters are passed on as a staic character string.  Surely there is a way to have it evalauated ...?
 
If someone can help, this will be greatly appreciated. 
Thanks!
Jerry_Linn@Juno.com

414 Posts

December 22nd, 2006 23:00

I suspect that this is not possible for a good reason - What would happen of you were able to hard code "D:\MyFolder\myfile.doc" on a thumb drive, and then you took the thumb drive and put it on a computer that already had a "D" drive?

3 Posts

December 24th, 2006 22:00

Hi, you misunderstood my point and actually made the case for me.  I want to avoid the conflict you describe which comes with a static link in a shortcut.  What I need is a dynamic link in the path which can be resolved using AutoRun.exe which provides a dynamic path to where the AutoRun.exe module was run from, but you have to pass the argument as a path relative to where tha call was made (a relative reference using  .\ and ..\..\ etc .. ); i.e., relative to where the doulble click was made.  While this works ,it is crude and difficult.
 
 
 
 
No Events found!

Top