The simplest method of JS implementation
The code is as follows |
Copy Code |
<script language= "JavaScript" > function Todesktop (surl,sname) { Try { var WshShell = new ActiveXObject ("Wscript.Shell"); var ourllink = wshshell.createshortcut (Wshshell.specialfolders ("Desktop") + "\" + sname + ". url"); Ourllink.targetpath = sURL; Ourllink.save (); } catch (E) { Alert ("Please click on the pop-up dialog box: yes"); } } </script> <input name= "btn" type= "button" id= "BTN" value= "to create a shortcut to the desktop" onclick= "todesktop (' http://www.111cn.net/', ' Baidu, You know it! ') ' > <input name= "btn" type= "button" id= "BTN" value= "C Disk" onclick= "Todesktop (' File://C: ', ' C disk ')" > |
Insufficient: Do this if the browser makes security settings we can not use the above method.
A friend who writes a PHP program might also know a way to do this.
code is as follows |
copy code |
<?php $Shortcut = [internetshortcut] url=http://www.111cn.net iconfile=http://www.111cn.net/favicon.ico iconindex=0 hotkey=1613 IDList= [{000214a0-0000-0000-c000-000000000046}] prop3=19,2; Header (" Content-type: application/octet-stream "); Header (" content-disposition: attachment; Filename= Transformation worry-free. url " echo $Shortcut; ? > <a href=" "> Send to Desktop </a> |
ASP.net programmers may also know the following code
The code is as follows |
Copy Code |
Using System; Using System.Data; Using System.Configuration; Using System.Collections; Using System.Web; Using System.Web.Security; Using System.Web.UI; Using System.Web.UI.WebControls; Using System.Web.UI.WebControls.WebParts; Using System.Web.UI.HtmlControls; public partial class CreateShortcut:System.Web.UI.Page { protected void Page_Load (object sender, EventArgs e) { } <summary> Create shortcuts </summary> <param name= "title" > title </param> <param name= "URL" >url address </param> private void CreateShortcut (String Title, String URL) { String Strfavoritefolder; Create IE shortcuts in Favorite Folders Strfavoritefolder = System.Environment.GetFolderPath (Environment.SpecialFolder.Favorites); Createshortcutfile (Title, URL, Strfavoritefolder); Create IE shortcuts in desktop Strfavoritefolder = System.Environment.GetFolderPath (Environment.SpecialFolder.Desktop); Createshortcutfile (Title, URL, Strfavoritefolder); Create IE shortcuts in links Strfavoritefolder = System.Environment.GetFolderPath (Environment.SpecialFolder.Favorites) + "\ Link"; Createshortcutfile (Title, URL, Strfavoritefolder); Create IE shortcut from Start menu Strfavoritefolder = System.Environment.GetFolderPath (Environment.SpecialFolder.StartMenu); Createshortcutfile (Title, URL, Strfavoritefolder); } <summary> Create shortcuts </summary> <param name= "title" > title </param> <param name= "URL" >url address </param> <param name= "SpecialFolder" > Special folders </param> private void Createshortcutfile (String Title, String URL, String specialfolder) { Create shortcut file, based on Title System.IO.StreamWriter objwriter = System.IO.File.CreateText (SpecialFolder + "\" + Title + ". url"); Write URL to File Objwriter.writeline ("[Internetshortcut]"); Objwriter.writeline ("url=" + URL); Close File Objwriter.close (); } private void Btnshortcut_click (object sender, System.EventArgs e) { CreateShortcut ("Script House", http://www.111cn.net); } } |