473,378 Members | 1,390 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Getting a target Path from having the path name as a string

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
Jul 17 '07 #1
5 2077
hariharanmca
1,977 1GB
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

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.     MsgBox GetTargetPath("ShortCut Filename")
  3. End Sub
  4.  
  5. Pivate Function GetTargetPath(ByVal FileName As String)
  6.     Dim Obj As ObjectSet
  7.     Obj = CreateObject("WScript.Shell")
  8.     Dim Shortcut As ObjectSet
  9.     Shortcut = Obj.CreateShortcut(FileName)
  10.     GetTargetPath = Shortcut.TargetPathShortcut.Save
  11. End Function
i think this will help you
Jul 17 '07 #2
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.     MsgBox GetTargetPath("ShortCut Filename")
  3. End Sub
  4.  
  5. Pivate Function GetTargetPath(ByVal FileName As String)
  6.     Dim Obj As ObjectSet
  7.     Obj = CreateObject("WScript.Shell")
  8.     Dim Shortcut As ObjectSet
  9.     Shortcut = Obj.CreateShortcut(FileName)
  10.     GetTargetPath = Shortcut.TargetPathShortcut.Save
  11. End Function
i think this will help you
It states that Type ObjectSet is not defined. How do I fix that?
Jul 17 '07 #3
hariharanmca
1,977 1GB
It states that Type ObjectSet is not defined. How do I fix that?

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.     MsgBox GetTargetPath("ShortCut Filename")
  3. End Sub
  4.  
  5. Pivate Function GetTargetPath(ByVal FileName As String)
  6.     Dim Obj As Object
  7.     Set Obj = CreateObject("WScript.Shell")
  8.     Dim Shortcut As ObjectSet
  9.     Shortcut = Obj.CreateShortcut(FileName)
  10.     GetTargetPath = Shortcut.TargetPathShortcut.Save
  11. End Function
okay, its an typo.....

Expand|Select|Wrap|Line Numbers
  1.     Dim Obj As Object
  2.     Set Obj = CreateObject("WScript.Shell")
Jul 17 '07 #4
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.     MsgBox GetTargetPath("ShortCut Filename")
  3. End Sub
  4.  
  5. Pivate Function GetTargetPath(ByVal FileName As String)
  6.     Dim Obj As Object
  7.     Set Obj = CreateObject("WScript.Shell")
  8.     Dim Shortcut As ObjectSet
  9.     Shortcut = Obj.CreateShortcut(FileName)
  10.     GetTargetPath = Shortcut.TargetPathShortcut.Save
  11. End Function
okay, its an typo.....

Expand|Select|Wrap|Line Numbers
  1.     Dim Obj As Object
  2.     Set Obj = CreateObject("WScript.Shell")
I really appreciate all the help. I am receiving this error when I debug at the line
GetTargetPath = Shortcut.TargetPathShortcut.Save

Public member 'TargetPathShortcut' on type 'IWshShortcut' not found.
Jul 17 '07 #5
Awesome I got it! My final code is:



Private Sub Command1_Click()

MsgBox GetTargetPath("ShortCut Filename")

End Sub


Private Function GetTargetPath(ByVal FileName As String)

Dim Obj As Object

Obj = CreateObject("WScript.Shell")

Dim Shortcut As Object

Shortcut = Obj.CreateShortcut(FileName)

GetTargetPath = Shortcut.TargetPath
End Function


Thank you so much!
Jul 17 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Amir Hardon | last post by:
I am dynamically adding rows to a table, and each row have a button which removes it. I have successfully implemented this for mozilla but I'm having troubles with IE, here is how I did it: ...
5
by: SimonH | last post by:
Hi all, I'm having problems identifying how to get the last directoy in a path string. For example, in the Path 'C:\dir1\dir2\dir3' I want to be able to get the name dir3 I've tried the...
21
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does...
5
by: Yoshitha | last post by:
Hi I am working on a web project. I have a InstallerClass in my project. While making setup ( using web setup template) for this web application, I have added a userinterface with 4...
3
by: Hitesh | last post by:
Hi, I am getting the response from another Website by using the HttpHandler in my current site. I am getting the page but all the images on that page are not appearing only placeholder are...
27
by: Deek | last post by:
I have a target(graphic) that moves via, i am trying to detect a hit of the target with and essay(copied below) my prof gave us, but I am not sure what to do, if you could get me going in the...
0
by: ruju00 | last post by:
I am getting an error in Login() method of the following class FtpConnection public class FtpConnection { public class FtpException : Exception { public FtpException(string message) :...
0
by: buntyindia | last post by:
Hi, I have a very strange problem with my application. I have developed it using Struts. I have a TextBox With Some fixed value in it and on Submit iam passing it to another page. <html:form...
14
by: anju458 | last post by:
Hi, I had a function to compare two XML files within a project . Now I need to change that into a commandline exe in such a way that it whouls accept two params from the Command line. I have...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.