开发者

How to change an Internet ShortCut .url file in c# and Windows 7 [closed]

开发者 https://www.devze.com 2023-02-14 06:33 出处:网络
Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed. This question is off-topic. It is not currently accepting answers.

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 11 years ago.

Improve this question

Note: All of the following has been performed on a Windows 7 computer..

I have been attempting to programatically create internet shortcuts.

These are essentially text files with a .url extension.

Here is the contents of one I created earlier..

[InternetShortcut]

URL=http://stackoverflow.com/

So I can successfully create this with a System.IO.File.WriteAllText() call. Test the shortcut and it works fine, but here is the problem, try and change it! By this I mean I have some code that attempts to change the URL. I delete the previous file and create a new one, (with the same name) but a different URL and it does not work?

Even try doing this in notepad. Cratea a .url file in notepad with the contents listed above. Follow the shortcut and confirm it works.

Open the .url file in notepad and change the URL from "http://stackoverlfow.com" to "http://www.google.com", save it, and view the properties of the file. You will find the following:

  1. On the "Web Document" tab the URL says http://stackoverfl开发者_JS百科ow.com.
  2. On the "Details" tab the URL says http://www.google.com
  3. Double click on it and it goes to the "web document" location.

It appears to be cached somehow. Save a copy with a different name i.e do ctrl+c ctrl+v and the copied internet short cut has both tabs showing http://www.google.com.

All of the above was done on a Windows 7 box. I tried the same on an XP box and the results were slightly different. The properties of the shortcut still display the first url that you enter, but following the link will direct the whatever you have in the text file.

I have seached the registry and cannot file any references to the URL. I have both IE and firefox and get the same result regardless of which browser is set as default

Anyone else experience the same problem? Any suggestions?


Found it. It appears I lied. The difference appears to be the default browser. My XP box has IE as the default browser whilst my windows 7 box has Firefox as the default. I set my windows 7 box to use IE as the default browser and the .url shortcuts work. It appears to be an issue with the way Firefox interprets the URL link, combined with the fact that the "Web Document" tab doesn't update.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号