×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Retrieve Shortcut Properties

Retrieve Shortcut Properties

Retrieve Shortcut Properties

(OP)
I know that using the CreateShortcut method that you can define properties for a shortcut and then create it wherver you like, but my question is can these properties be retrieved from an existing shortcut?

What I really want to do (in case there's an easier way round it), is to find out what icon file a given shortcut is using?

Any ideas?
Any help much appreciated.

Cheers,
Dan.

RE: Retrieve Shortcut Properties

Hello Beard36,

Vbscript documentation has CreateShortCut method, whereas the delete, copy and move are managed by fso. Related to your question in particular, there lacks singularly "GetShortCut" method.

With the above introduction in mind, the inexistent "GetShortCut" is actually realized by CreateShortCut of an _existing_ shortcut, and the properties are then automatically made available to the object (read-write).

CODE

Set Shell = CreateObject("WScript.Shell")
DesktopPath = Shell.SpecialFolders("Desktop")
Set link = Shell.CreateShortcut(DesktopPath & "\winipcfg.lnk")
link.Arguments = ""
link.Description = "winipcfg shortcut"
link.HotKey = "CTRL+ALT+SHIFT+X"
link.IconLocation = ",0"
link.TargetPath = "c:\windows\winipcfg.exe"
link.WindowStyle = 1
link.WorkingDirectory = "d:\test"
link.Save
'Above modelling the documentation, the link is then created already.
'This is an undocumented feature.
'Re-create an existing link again to get to the preperties.

Set link = Shell.CreateShortcut(DesktopPath & "\winipcfg.lnk")
wscript.echo link.Description
wscript.echo link.IconLocation
wscript.echo link.Hotkey
wscript.echo link.WindowStyle
wscript.echo link.WorkingDirectory
'etc
set link=nothing

regards - tsuji

RE: Retrieve Shortcut Properties

(OP)
That's excellent, it really is!

Actually, now I look back under the "CreateShortcut Method" page on MSDN, it does state "Creates a new shortcut, or opens an existing shortcut" which I hadn't noticed before, especially as it makes no further mention of this retrieval ability anywhere else in the documentation.

Anyway, though, it works like a charm.

It seems every other thread I look at round here seems to have a solution posted by you - well done, you must be very wise! ;)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close