Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi..
I am a fresher and have created a web application and hosted it on IIS, now i want to create shortcut on client machines desktop which will contains url when user clicks shortcut it will go to that url. so i have tried Following code to do so and it is working on my machine but when i am try to execute from IIS it did not works.
So can some one please help me. To create Short cut on Client machine
C#
protected void LinkButton1_Click(object sender, EventArgs e)
{
HttpBrowserCapabilities bc = Request.Browser;

string browserName = bc.Browser;
dynamic wsh = Microsoft.VisualBasic.Interaction.CreateObject("WScript.Shell");

wsh = Microsoft.VisualBasic.Interaction.CreateObject("WScript.Shell");

dynamic MyShortcut = null;

dynamic DesktopPath = null;

DesktopPath = wsh.SpecialFolders("Desktop");

MyShortcut = wsh.CreateShortcut(DesktopPath + "\\MyShortcut1.lnk");

MyShortcut.Arguments = "www.yahoo.com";

MyShortcut.Save();
}
Posted
Updated 9-Jan-12 4:19am
v2
Comments
Catalin Serafimescu 9-Jan-12 10:35am    
Usually web links are saved in Favorites. User can type CTRL-D and this is all.

This can't be done, and for good reason – websites don't (and never should) have access to the client machine outside the browser.

Simply tell your users to drag a link or URL onto the desktop, if they're using Windows.
 
Share this answer
 
Comments
bbirajdar 10-Sep-20 9:21am    
Agreed
A web application runs inside the web browser and is not allowed to access any of the user's system resources outside the browser. So a web app cannot create a shortcut on user's desktop. You need to instruct the user to create the shortcut to his desktop. If he wants then he will create the shortcut otherwise not.

The code you have written executes on the server ( or your localhost) and creates the short cut there. But for a user, the code executes on the remote machine and NOT on his machine for the short cut to be created. Understand the client-server architecture. Its simply NOT possible.

Have you seen any such functionality on any other website ?
 
Share this answer
 
v2
Comments
Harris.P.Nair 23-May-20 4:50am    
but if you are using amazon.in on your mobile phone, it will ask you if you want to add a shortcut on your home screen. by one click it will create a shortcut button on your home screen.
bbirajdar 10-Sep-20 9:20am    
You need to understand that Amazon app is a native app on Android phone and not a web app.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900