Add Reference (com->windows Script Host Object Model)
/*
Description: A shortcut that has the same name will overwrite the previous shortcut when it is created
*/
Using Iwshruntimelibrary;
private static void Createdesktoplnk ()
{
String DesktopPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Desktop);//Get Desktop Folder
Iwshruntimelibrary.wshshell shell = new Iwshruntimelibrary.wshshellclass ();
Iwshruntimelibrary.iwshshortcut shortcut = (iwshruntimelibrary.iwshshortcut) shell. CreateShortcut (DesktopPath + "\\ERP system. Lnk");
Shortcut. TargetPath = @ "D:\software\cmpc\zy.exe";
Shortcut. Arguments = "";//Parameter
Shortcut. Description = "ERP system";
Shortcut. WorkingDirectory = @ "D:\software\cmpc\";//the folder where the program is located, right-click on the shortcut icon to see this property
Shortcut. IconLocation = @ "d:\software\cmpc\zy.exe,0";//Icon
Shortcut. Hotkey = "ctrl+shift+z";//Hotkey
Shortcut. WindowStyle = 1;
Shortcut. Save ();
/*
* Shortcuts to Websites
Iwshruntimelibrary.iwshshortcut shortcut = (iwshruntimelibrary.iwshshortcut) shell. CreateShortcut (DesktopPath + "\ \ Auto Create +.lnk");
Shortcut. TargetPath = @ "%homedrive%/program files\internet Explorer\iexplore. EXE ";
Shortcut. Arguments = "http://www.baidu.com";//Parameters
Shortcut. Description = "Shortcut link to website";
Shortcut. WorkingDirectory = application.startuppath;//The folder where the program is located, right-click on the shortcut icon to see this property
Shortcut. IconLocation = @ "%homedrive%/program files\internet Explorer\iexplore. EXE, 0 ";//Icon
Shortcut. Hotkey = "ctrl+shift+z";//Hotkey
Shortcut. WindowStyle = 1;
Shortcut. Save ();
*/
}
C # Create desktop shortcuts