示例#1
0
        public void appshortcut()
        {
            // Create a Windows Script Host Shell class

            IWshShell_Class shell = new IWshShell_Class();

            // Define the shortcut file

            //IWshURLShortcut shortcut = shell.CreateShortcut(location1) as IWshURLShortcut;

            IWshShortcut_Class shortcut = shell.CreateShortcut(location2) as IWshShortcut_Class;


            shortcut.WorkingDirectory = @"E:\Program Files (x86)\KuGou\KGMusic";
            shortcut.TargetPath       = @"E:\Program Files (x86)\KuGou\KGMusic\KuGou.exe";
            // Save it

            shortcut.Save();
        }
示例#2
0
        public void creatdesktop()

        {
            string app = Environment.CurrentDirectory + @"\_58.exe";

            try
            {
                // Create a Windows Script Host Shell class
                IWshShell_Class shell = new IWshShell_Class();
                // Define the shortcut file
                IWshShortcut_Class shortcut = shell.CreateShortcut(app + ".lnk") as IWshShortcut_Class;
                // Set all its properties
                shortcut.Description  = "Smart sample of creating shell shortcut";
                shortcut.TargetPath   = app;
                shortcut.IconLocation = app + ",0";
                // Save it
                shortcut.Save();
            }
            catch (COMException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }