Jump to content

Recommended Posts


Posted

This should do:

@ECHO OFF
IF %1.==. GOTO :EOF
IF NOT EXIST %~dpnx1 GOTO :EOF
ECHO %~dpnx1
IF NOT %~x1.==.lnk. GOTO :EOF
more %~dpnx1 | FIND ":\" | FIND /V "/"
pause

jaclaz

Posted

The following works with Win7 shortcuts.

@More "%~dpn1.lnk" 2>Nul|Findstr ":\\."&&Ping -n 6 127.0.0.1>Nul

Just drag and drop the shortcut onto it to see it in action.

Posted

Here is the VBS script way of getting the lnk path. This script can handle multiple .lnk files being drag and drop on to it self.

 Dim Obj, Act :Set Act = CreateObject("WScript.Shell")
If Not Wscript.Arguments.Count = 0 Then
For Each Obj In WScript.Arguments
If InStr(LCase(obj),LCase(".lnk")) Then
Act.Popup vbCrLf & Act.CreateShortcut(obj).TargetPath,5,"ShortCut Path",4128
End If
Next
End If

  • 2 months later...
Posted

first-of thanks for the help guys

Had problems posting lately &thanks is due...

now to further refine Yzöwl's code that worked here in batch :

from the current batch output result * how to omit just the "\target.file" (from the right end of the line & so that only the path folder directory is shown.)

thanks

Posted

You'll need to use a few more lines by implementing a 'For loop'

Something like this should do:

@Echo off & Setlocal & Set "P_="
If "%~1" Neq "" (If Exist "%~1" (If /I %~x1 Equ .lnk (
For /F "tokens=*" %%# In ('More "%~f1"^|Findstr ":\\."') Do (
Set "P_=%%~dp#"))))
If Defined P_ (Set "P_=%P_:~,-1%" & Call Echo/%%P_%% & Ping -n 6 127.0.0.1>Nul)

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...