C#生成桌面快捷方式

  ///


        /// 生成桌面快捷方式
        /// 当前路径: @"D:\SmartEnvironmentInstaller\SmartStart\SmartEnviroment.exe";//指定目标路径
        ///

        private void CreateShortcutOnDesktop()
        {
            string shortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "SmartLaser.lnk");
            IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell();
            IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(shortcutPath);//创建快捷方式对象
            shortcut.TargetPath = @"D:\SmartEnvironmentInstaller\SmartStart\SmartEnviroment.exe";//指定目标路径
            shortcut.WorkingDirectory = Path.GetDirectoryName(@"D:\SmartEnvironmentInstaller\SmartStart");//设置起始位置
            shortcut.WindowStyle = 3; //目标应用程序的窗口状态分为普

你可能感兴趣的:(c#,java,开发语言)