Hi 65sametkaya65,
Use IWshRuntimeLibrary.
Right click on the Project -> Add -> Reference.
Select COM tab and look for Windows Script Host Object Model.
Check the CheckBox and click OK.
Then refer the code.
Namespaces
using IWshRuntimeLibrary;
Controller
public class HomeController : Controller
{
// GET: Home
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Save()
{
object shDesktop = (object)"Desktop";
WshShell wshShell = new WshShell();
string shortcutAddress = (string)wshShell.SpecialFolders.Item(shDesktop) + @"\Notepad.lnk";
IWshShortcut iWshShortcut = (IWshShortcut)wshShell.CreateShortcut(shortcutAddress);
iWshShortcut.Description = "Notepad shortcut";
iWshShortcut.Hotkey = "Ctrl+Shift+N";
iWshShortcut.TargetPath = Environment.GetFolderPath(Environment.SpecialFolder.System) + @"\notepad.exe";
iWshShortcut.Save();
return View("Index");
}
}
View
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
@using (Html.BeginForm("Save", "Home", FormMethod.Post))
{
<input type="submit" value="Save" />
}
</body>
</html>