Web page Create shortcuts to desktop multiple methods

Source: Internet
Author: User

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);
}
}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.