Link to home
Get AccessLog in
Avatar of Laptop

asked on

How to capture the target path of the Link file (*.lnk) ???

How to capture the target path of the link file ( *.lnk).
For eg.
I 've a link file named iexplore.lnk in the system ,for this file how can I  capture the target path ("C:\Program Files\Internet Explorer\IEXPLORE.EXE")
in the variable thru. Vusual Basic when I execute the my VB Program.

I wanted this code so as to capture this path at run time & execute all the lnk files automatically.

if u Right Click the lnk file extension u get a menu popup & click the Properties in the popup menu a window 'll be opened , in that click the shortcut tab , u find the Target where the path & EXE of that will be displayed.I wanted to capture that in VB at run time.

Pls. do suggest in this regard. Kindly help me.

Avatar of crazyman
Flag of United Kingdom of Great Britain and Northern Ireland image

Take a look here.
cost you 5 points but trust me the answer is there.
Avatar of mcrider

Link to home
This content is only available to members.
To access this content, you must be a member of Experts Exchange.
Get Access
Nice code mcrider!  Good for 100 pts I'd say (<Ctrl-X, Ctrl-V, Grin! ;>)
Avatar of mcrider

Well Paul... You know... You could open a question for me and credit that (<Ctrl-X, Ctrl-V, Grin! ;>)


1. Start a New Standard.Exe Project.
2. Add a reference (VB Menu -> Project -> References) to the "Windows Scripting Host Object Model".
3. Copy/Paste the following into the Form1 code window.
4. CHANGE the strLinkName variable to a valid Shortcut.
5. Press F5 to run. Click on VB Menu -> View -> Immediate Window and you will see all pertinent Shortcut information for the Link listed in the Immediate Window.

<----- Code begin ----->

Option Explicit

Private Sub Form_Load()

   Dim strLinkName As String
   strLinkName = "c:\windows\desktop\windows explorer.lnk" ' <-- CHANGE
   Dim wshShell As New IWshShell_Class
   Dim wshLink As IWshShortcut_Class
   Set wshLink = wshShell.CreateShortcut(strLinkName)
   Debug.Print "Arguments: " & wshLink.Arguments
   Debug.Print "Description: " & wshLink.Description
   Debug.Print "FullName: " & wshLink.FullName
   Debug.Print "HotKey: "; wshLink.Hotkey
   Debug.Print "IconLocation: " & wshLink.IconLocation
   Debug.Print "TargetPath: " & wshLink.TargetPath
   Debug.Print "WindowStyle: " & wshLink.WindowStyle
   Debug.Print "WorkingDirectory: " & wshLink.WorkingDirectory
   Unload Me

End Sub

<----- Code End ----->

wsh2, pushing that windows scripting host again huh? ;-) Alot of folks are getting rid of it after the ILU virus...

I deal with 15 companies now that have removed the Scripting Host from all of their systems and software written for them that uses it has to be rewritten...

Hi mc.. <smile>

Ditching WSH, huh?.. They must have all talked to my wife.. LOL.

Ya know.. I'm kinda in agreement with these people.. while they are at why not also axe JavaScript and VbScript.. and OMG, how about those pesky little DOS BAT files? The more I think about it.. the bulk of the viruses I have encountered have been written in C.. I say shitcan that technical tool as well. Oh.. and how about that MS-Outlook Service Pack.. with 83 file extensions now precluded from EMail.. with tomorrow only bringing us more.

Heck.. after we eliminate ALL computer files.. we can ban Typewriters (no ransom notes).. Spray paint (no offensive graffitti).. and guns.. er wait.. still hoping here that someone shoots Ronald Reagan.. after that.. then no guns will be perfectly  alright.. <j/k-lol>. Gawd how I miss Senator Joe McCarthy.. <longing sigh>.

Microsoft still maintains that they are going to support WSH and as such that is good enough for me to continue to use it <offthread.. WSH deploys with IE4/5 and other software packages I am sure - how ya going to stop it?>. WSH is a tool.. as are DOS, Java, the Windows API, C/C++ and Visual Basic each of which can do justas much, if not more damage. Despite that.. I promise you.. that I will stand by my Justice League of America superhero oath.. and only use my WSH powers for good.. and NOT for evil! (Besides.. I can code what you did in about 10% of the lines.. nanananananana <tongue out>.. LOL.. <now running and ducking>)

Mc.. as always.. I do appreciate all of your thoguhts and comments.. <smile>. Nevertheless.. when it comes to WSH.. <donning his Rambo headband and dual M-60 .30 caliber machine guns>.. I do plan to live dangerous.. even though I believe this to be.. <now going for the big English Literature points.. ie "W"illiam "SH"akespeare).. "much ado about nothing".. <smile>. Now where was I... "Yo Momma.. wanna nickel bag of WSH?".. heheheheheheheh.

Catch ya later mc.. <smile>.

Actually, a couple of those companies have turned off all scripting... but then two of them have a perfect right to be paranoid... Sittin' there behind their firewalls (a bank and a brokerage firm) countin' their money.

Can you believe it, the bank doesn't allow people to even surf freely... Joe McCarthy Lives!! <VBG>

Personally, I've made a decision not to recommend WSH to anyone anymore because it's been such a touchy subject over the last couple of weeks... I also think you should contact Linda and have her change your userid... Besides, you may get sued my Billysoft when they come out with WSH2.... Maybe you'll luck out and they'll call it WSH-TNG... Just rambling... ;-)

mcrider, If I needed it right now I might.  Just saving some code for a rainy day.
Yea, when it rains it pours! <VBG>
Avatar of Laptop


Adjusted points from 20 to 30
Avatar of Laptop


Answer accepted
Thanks for the points! Glad I could help!