I have the shortcut path name as a string "C:\test\batch1 .bat.lnk" for example. Is there anyway I can get the target path from that. I'm using VB 2005 Express
Getting a target Path from having the path name as a string
Collapse
X
-
Originally posted by NyNyHelpI have the shortcut path name as a string "C:\test\batch1 .bat.lnk" for example. Is there anyway I can get the target path from that. I'm using VB 2005 Express
Code:Private Sub Command1_Click() MsgBox GetTargetPath("ShortCut Filename") End Sub Pivate Function GetTargetPath(ByVal FileName As String) Dim Obj As ObjectSet Obj = CreateObject("WScript.Shell") Dim Shortcut As ObjectSet Shortcut = Obj.CreateShortcut(FileName) GetTargetPath = Shortcut.TargetPathShortcut.Save End Function
-
Originally posted by hariharanmcaCode:Private Sub Command1_Click() MsgBox GetTargetPath("ShortCut Filename") End Sub Pivate Function GetTargetPath(ByVal FileName As String) Dim Obj As ObjectSet Obj = CreateObject("WScript.Shell") Dim Shortcut As ObjectSet Shortcut = Obj.CreateShortcut(FileName) GetTargetPath = Shortcut.TargetPathShortcut.Save End Function
Comment
-
Originally posted by NyNyHelpIt states that Type ObjectSet is not defined. How do I fix that?
Code:Private Sub Command1_Click() MsgBox GetTargetPath("ShortCut Filename") End Sub Pivate Function GetTargetPath(ByVal FileName As String) Dim Obj As Object Set Obj = CreateObject("WScript.Shell") Dim Shortcut As ObjectSet Shortcut = Obj.CreateShortcut(FileName) GetTargetPath = Shortcut.TargetPathShortcut.Save End Function
Code:Dim Obj As Object Set Obj = CreateObject("WScript.Shell")
Comment
-
Originally posted by hariharanmcaCode:Private Sub Command1_Click() MsgBox GetTargetPath("ShortCut Filename") End Sub Pivate Function GetTargetPath(ByVal FileName As String) Dim Obj As Object Set Obj = CreateObject("WScript.Shell") Dim Shortcut As ObjectSet Shortcut = Obj.CreateShortcut(FileName) GetTargetPath = Shortcut.TargetPathShortcut.Save End Function
Code:Dim Obj As Object Set Obj = CreateObject("WScript.Shell")
GetTargetPath = Shortcut.Target PathShortcut.Sa ve
Public member 'TargetPathShor tcut' on type 'IWshShortcut' not found.Comment
-
Awesome I got it! My final code is:
Private Sub Command1_Click( )
MsgBox GetTargetPath(" ShortCut Filename")
End Sub
Private Function GetTargetPath(B yVal FileName As String)
Dim Obj As Object
Obj = CreateObject("W Script.Shell")
Dim Shortcut As Object
Shortcut = Obj.CreateShort cut(FileName)
GetTargetPath = Shortcut.Target Path
End Function
Thank you so much!Comment
Comment