Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Editing .lnk files on another machine?

Status
Not open for further replies.

jsteph

Technical User
Oct 24, 2002
2,562
US
When I try to edit a .lnk shortcut on another machine, Windows does not allow me to save the true shortcut for *that* machine. It gives me the error about Can't find the program...blah, blah.

While I appreciate the warning, I would like the option of being able to save the path that I know is correct for that machine--or for that matter--even an incorrect path that may in a few days exist.

I suppose it's too much to ask a 'network aware' OS to know enough to know that the shortcut is not actually on the local machine but on the network--so it could forego the local-path validity check . But that would just degrade into a rant....

I even tried to rename the thing with a .txt extension since I thought it might have the path info in some sort of file format, even binary, but here Windows goes the extra mile and torpedoes that by allowing the .txt extension, but somehow (in this case only!) it knows what kind of file it is based on the contents rather than the extension.

Thanks for any help in how to set up a remote user with a shortcut...without having to re-create the path on my own machine.
--Jim
 
You should be able to do this...

Browse to the file on the user's PC and right-click and select Create ShortCut. Cut/Paste to the location where the user needs it.


--
Not until I became a Network Administrator did the error message "See your Network Administrator for assistance" become petrifying.
 
Thhis is why it seldom works to try and copy shortcuts between workstations either.

I do not know of a workaround, but there may well be one. The only ones I have seen write the .lnk files directly using scripting through the logon script or using something like psexec --
 
Mike,
That's not really what I need. That will 'create' a shortcut, but I need to edit one, ie, add my own command-line arguments, etc. So I can create one via that method, but when I go to edit it, it will not let me save it, because it was created using the remote machine's path, which does not exist on my machine.

bcastner,
Thanks, I will check into the scripting and see if I can make something work. I guess this is similar to a question I'd asked earlier about Tasks--when you look in a remote computer's C:\Windows\Tasks folder--you're looking at your own Tasks! Very dangerous in my opinion...
--Jim
 
WSH .lnk creation script

'Used to create a shortcut
Dim Shell As WshShell
Dim Shortcut As WshShortcut

Place the following lines in your Sub:

'This initializes the object WshShell
Set objShell = New WshShell

'This initializes the object WshShortcut
'Place the complete path to where you want to create the .LNK file. You must include the .LNK extension
Set objShortcut = objShell.CreateShortcut(Your .LNK file path here)

'Place the Target path here. Note the target path is the path to the exe file you are creating the shortcut for.
objShortcut.TargetPath = Target path here.

'optional - any command line supported by the file indicated in txtTarget.Text
'objShortcut.Arguments = xxxx

'optional - a valid icon file : = Note if you are using the same icon as the target do not use the line below.
objShortcut.IconLocation = Icon path here

'Saves the shortcut.
objShortcut.Save
====================================

If the target location will the the user's Desktop:

Using the code above dim another string variable something like strMyDesktpPth = WshShell.SpecialFolders("Desktop") then use this variable in the following line:
Set objShortcut = objShell.CreateShortcut(strMyDesktpPth & "\Myfile.lnk")



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top