windows 以编程方式在用户桌面上创建 Web 快捷方式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/539962/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Creating a web shortcut on user desktop programmatically
提问by Renaud Bompuis
There are quite a few resources for programmatically creating .lnk
type shortcuts to files and programs on the desktop but I'm wondering how to create a shortcut to a web URL.
有很多资源可用于以编程.lnk
方式为桌面上的文件和程序创建类型快捷方式,但我想知道如何创建指向 Web URL 的快捷方式。
From what I can gather, the web URL shortcut is a text file ending in .URL
and contains a ini-like definition such as:
据我所知,Web URL 快捷方式是以文本文件结尾.URL
并包含类似 ini 的定义,例如:
[InternetShortcut]
URL=http://www.google.com/
However, it's not enough to just create the file, it seems you also need to change its meta URL
properties to include the same link.
但是,仅仅创建文件是不够的,您似乎还需要更改其元URL
属性以包含相同的链接。
Any idea how to create these?
知道如何创建这些吗?
Any sample code from .Net/Perl/batch is welcome.
欢迎任何来自 .Net/Perl/batch 的示例代码。
回答by Andrew Ensley
You can create .lnk shortcuts to any URI, including web addresses. Just create the shortcut and make the target your web address instead of a file location.
您可以为任何 URI(包括 Web 地址)创建 .lnk 快捷方式。只需创建快捷方式并将目标设为您的网址而不是文件位置。
See this other question for how to do it programmatically:
有关如何以编程方式执行此操作,请参阅另一个问题: