Show Shortcut Target Paths with VBS

12/14/07

Permalink 10:44:15 am, by dave Email , 188 words, 235 views   English (US)
Categories: Windows Scripting, Wsh Scripts

Show Shortcut Target Paths with VBS

I was working on a script to
enumerate what files were being executed in the startup folder
. To do this, I needed to determine what executables were pointed to from the shortcut (.lnk) files that were in the startup folder. Here is a function that wraps everything up and will return the target path for the shortcut.

[More:]

function getLinkPath( lnkPath )

dim objLink, retVal, wshShell

set wshShell = createobject("WScript.Shell")

set objLnk = wshShell.createshortcut(lnkPath)

retVal = objLnk.targetpath

set objLnk = nothing

getLinkPath = retVal

set wshShell = nothing

end function

To call the function, pass the full path to link file.....something like....

wscript.echo getLinkPath( "C:\Documents and Settings\All Users\Start Menu\Programs\Startup\Install Pending Files.lnk" )

This will return the path of the target file, something like.....

C:\>cscript funcTest.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

C:\Program Files\SIFXINST\SIFXINST.EXE

I hope this post helped you out. If it didn't, I am always looking for new scripts to add so submit a request for your question or need and I will see if I can answer it.



Did you like this post? If so, Share it!  del.icio.us digg reddit slashdot this article Facebook Twitter MySpace Email



Pingbacks:

No Pingbacks for this post yet...

Scripts

This is somewhere I can post interesting snippets as I come across them. Hopefully some folks out there will find this helpful.

Search

Follow Me:

Misc

Who's Online?

  • Guest Users: 1

powered by b2evolution free blog software