sweept Posted October 9, 2009 Posted October 9, 2009 I need a batch that will tell the targets path from dragging a lnk file on to it ...thanks
jaclaz Posted October 9, 2009 Posted October 9, 2009 This should do:@ECHO OFFIF %1.==. GOTO :EOFIF NOT EXIST %~dpnx1 GOTO :EOFECHO %~dpnx1IF NOT %~x1.==.lnk. GOTO :EOFmore %~dpnx1 | FIND ":\" | FIND /V "/"pausejaclaz
Yzöwl Posted October 9, 2009 Posted October 9, 2009 The following works with Win7 shortcuts.@More "%~dpn1.lnk" 2>Nul|Findstr ":\\."&&Ping -n 6 127.0.0.1>NulJust drag and drop the shortcut onto it to see it in action.
gunsmokingman Posted October 9, 2009 Posted October 9, 2009 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
sweept Posted January 4, 2010 Author Posted January 4, 2010 first-of thanks for the help guysHad 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
Yzöwl Posted January 4, 2010 Posted January 4, 2010 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)
sweept Posted February 24, 2010 Author Posted February 24, 2010 so far this worked perfectly for me .. thanks again!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now