views:

150

answers:

2

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.

A: 

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.

Ken White
+3  A: 

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.

Agent_9191
Well then I guess my batch file can generate the .vbs file on the fly, and then execute it. Yeah! Ugh!
Chris Noe
I've done uglier hacks than that to execute simple tasks
Agent_9191