?
Solved

Get URL from an Internet Shortcut file

Posted on 2003-11-25
3
Medium Priority
?
878 Views
Last Modified: 2006-11-17
I'm using VB.Net and I'm trying to get the URL for an Internet Shortcut given that I already have the filename. For example, I have a shortcut for http://www.yahoo.com stored on my computer as: c:\yahoo.url. When I right click the file in Windows Explorer and go to Properties, there's a property called "URL" listed. It's same URL that you get when you double-click the file. I've been playing around with the FileInfo class, but haven't had any luck.

Thanks, Zack Trainor
0
Comment
Question by:Ztrain2100
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
HappyParrot earned 1000 total points
ID: 9831455
Those are called Shell links in MSDN terminology not shortcuts, that's why finding info on them can be frustraiting
There are two ways that I know of for accoplishing that task: using Windows Scripting Host and using Shell Namespace from shell32.dll
I'll explain the first one, becouse I've never used the second :)
1) All you need to do is add the windows scripting host as a reference for your project (Just select "add reference..." and then select WSH from the COM objects section) then on top of your class file add an import directive:
"Imports IWshRuntimeLibrary" (for VB)
2) Then you simply create a shell object like that:
Dim myShell as new WshShell()  (again VB)
3) Create Shortcut variable:
Dim myLink as WshURLShortcut=myShell.CreateShortcut("link.url")
(if its just a regular link use WshShortcut)
And that's it... you can now retrive your URL string from myLink.TargetPath
0
 

Author Comment

by:Ztrain2100
ID: 9833277
Thank you very much for your response. That worked just great!
0
 
LVL 2

Expert Comment

by:HappyParrot
ID: 9833361
Glad to be of assistance
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question