Page 1 of 1 1
Topic Options
#64167 - 2002-03-28 08:33 PM Reading "Target" from Shortcut
Anonymous
Unregistered


How could I read the "Target" field from a shortcut? I would like to say If EXIST "target value of the shortcut" then delete the shorcut and copy/replace with new shortcut. I have some icons pointing to an old program that I want to point to the new version of the program. I want to get rid of the old icons and replace them with the new. Any ideas? Thanks.

Gordon

Top
#64168 - 2002-03-28 08:49 PM Re: Reading "Target" from Shortcut
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Take a look at the shortcut with NotePad. You should see that the target is in clear text. You can Open() ReadLine() and InStr() to ascertain.

You cold also use an external "Find" utility.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#64169 - 2002-03-28 08:59 PM Re: Reading "Target" from Shortcut
Anonymous
Unregistered


I tried just opening the shortcut with Notepad and it runs the executeable and dies. Any other way to read it?
Top
#64170 - 2002-03-28 09:01 PM Re: Reading "Target" from Shortcut
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Just overwrite the target shortcut if the time/date stamp is not identical to the original shortcut. If somebody modifies the shortcut, the time/date stamp gets updated. You can use COMPAREFILETIMES() for this. The additional advantage is that if you ever modify the original shortcut, the update will be distributed automatically.
_________________________
There are two types of vessels, submarines and targets.

Top
#64171 - 2002-03-28 09:58 PM Re: Reading "Target" from Shortcut
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Hey Gord,

If you've got windows scripting, you might try this little script. Place a shortcut called notepad.lnk on your desktop and this script will change the target pointer to wordpad ... worth a shot...

break on

$linkname = "%userprofile%\desktop\notepad.lnk"

$shell = createobject("wscript.shell")

$shortcut = $shell.createshortcut("$linkname")

if $shortcut.targetpath = "%windir%\system32\notepad.exe"
 $shortcut.targetpath = "%windir%\system32\write.exe"
 $shortcut.save
endif

$shortcut = nothing
$shell = nothing

exit 1


Hope this helps ...

-Shawn

[ 28 March 2002, 22:01: Message edited by: Shawn ]

Top
#64172 - 2002-03-28 11:19 PM Re: Reading "Target" from Shortcut
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I suspect you tried to "Open" the LNK via NotePad's dialog. Then yes, you would expect it not to work. If you want to see the LNK in NotePad, open NotePad first and then drag/drop the LNK into NotePad.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 756 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.056 seconds in which 0.027 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org