I have a subdir with a shortcut file in it, let's say it's "shortcut.lnk". and this item is pointing to some other location. when clicking on it in windows explorer the target subdir pops up.
How can I deal with that item using cmd.exe? How can I follow that shortcut using cmd.exe?
I probably don't want to add any third-party software but rather would like to stick and solve this with windows standard tools for portability reasons.
Run the application using a shortcut to cmd /kRight-click where you want the shortcut created and choose New → Shortcut. Type cmd.exe /k string , where string is the command you want to execute, then click Next. Give the shortcut an appropriate name and click Finish.
Go to the Shortcut tab, then locate the Target field, which lists the exact location of the file within quotation marks. In the Target text box, place the cursor after the last quotation mark, then add a blank space followed by the command line parameters. All command line parameters are preceded with a hyphen (-).
good old VBS seems to be the key for an evidently simple, short and on-board solution:
@echo off
Set Shortcut=%~1
echo set WshShell = WScript.CreateObject("WScript.Shell")>DecodeShortCut.vbs
echo set Lnk = WshShell.CreateShortcut(WScript.Arguments.Unnamed(0))>>DecodeShortCut.vbs
echo wscript.Echo Lnk.TargetPath>>DecodeShortCut.vbs
set vbscript=cscript //nologo DecodeShortCut.vbs
For /f "delims=" %%T in ( ' %vbscript% "%Shortcut%" ' ) do set target=%%T
del DecodeShortCut.vbs
Echo Shortcut %shortcut%
Echo Target "%target%"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With