Passing a shortcut to a batch script

552 Views Asked by At

My bat script accepts a filepath as a parameter, which allows me to drag-and-drop a file onto it from Explorer. Unfortunately when I drop a shortcut onto it, I simply get the filepath of the .lnk file itself, rather than the file that it refers to. Is there any way to derive the underlying filepath?

I am looking for a native capability in Windows XP that is directly available to bat/cmd without installing or configuring additional software.

2

There are 2 best solutions below

1
On BEST ANSWER

Via a batch file it's not possible. If you're looking for native capabilities on Windows, then I'd recommend a VBScript instead. Take a look at this question to see how to interact with the environment via VBScript to get the shortcut file and see it's target.

0
On

There's nothing available in Windows batch files (at least through Vista) that will allow you to resolve a shortcut back to it's actual target. That means there is no native capability in WinXP. You might be able to come up with something via PowerShell, but that's not native to either XP or Vista out of the box.