C # Create desktop shortcuts

Source: Internet
Author: User

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

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.