コード例 #1
0
        private void addShortCut(bool add)
        {
            String StartupFolder    = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
            String shortcutFilePath = StartupFolder + @"\Blurts.lnk";

            if (add)
            {
                // Add/create the shortcut to the Startup folder
                WshShellClass WshShell = new WshShellClass();
                IWshRuntimeLibrary.IWshShortcut MyShortcut;

                // The shortcut will be created in the Startup folder

                MyShortcut = (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(shortcutFilePath);

                //Specify target file full path
                MyShortcut.TargetPath       = Application.StartupPath + @"\Blurts.exe";
                MyShortcut.IconLocation     = Application.StartupPath + @"\blue1_32x32.ico";
                MyShortcut.WorkingDirectory = Application.StartupPath;

                //e.g.  MyShortcut.TargetPath = "C:\WINDOWS\system32\calc.exe"
                MyShortcut.Save();
            }
            else
            {
                //Remove the shortcut from the Startup folder
                if (System.IO.File.Exists(shortcutFilePath))
                {
                    System.IO.File.Delete(shortcutFilePath);
                }
            }
        }
コード例 #2
0
ファイル: InstalltionForm.cs プロジェクト: gob130/numchakra2
        private void CreateShortCutAtDestkop()
        {
            string targetdir     = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            string mShortcutPath = targetdir + "\\נומרולוגיית הצאקרות.lnk";
            string mAppPath      = mDestinationFolder + "\\NumChakra.exe";

            // Create a new instance of WshShellClass
            WshShellClass WshShell = new WshShellClass();

            // Create the shortcut
            IWshRuntimeLibrary.IWshShortcut MyShortcut;

            // Choose the path for the shortcut
            MyShortcut = (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(mShortcutPath);

            // Where the shortcut should point to
            MyShortcut.TargetPath = mAppPath;

            // Description for the shortcut
            MyShortcut.Description = "Launch Numerology Chakra Application";

            // Location for the shortcut's icon
            MyShortcut.IconLocation = mDestinationFolder + @"\CHKR_NUM.ico";

            // Create the shortcut at the given path
            MyShortcut.Save();

            //FileInfo fiSC = mDestFolder.GetFiles("*.lnk")[0];
            //fiSC.CopyTo(targetdir);
        }
コード例 #3
0
ファイル: ShortCutCreator.cs プロジェクト: rjt1014/MadCow
        public static void Create()
        {
            var WshShell = new WshShell();

            IWshRuntimeLibrary.IWshShortcut MyShortcut;

            MyShortcut                  = (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(@Environment.GetEnvironmentVariable("USERPROFILE") + "\\Desktop\\MadCow.lnk");
            MyShortcut.TargetPath       = Application.ExecutablePath;
            MyShortcut.WorkingDirectory = Environment.CurrentDirectory;
            MyShortcut.Description      = "MadCow";
            MyShortcut.Save();
        }
コード例 #4
0
        static void Main(string[] args)
        {
            if (args.Length == 1)
            {
                if (args[0] == "/u")
                {
                    try
                    {
                        IO.File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\StartGlashFish.lnk");
                        IO.File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\StopGlashFish.lnk");
                        IO.File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\MySql.lnk");
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
            else
            {
                WshShell = new WshShellClass();
                // Create the shortcut
                IWshRuntimeLibrary.IWshShortcut MyShortcut;
                // Choose the path for the shortcut
                string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\StartGlashFish.lnk";
                MyShortcut = (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(path);
                // Where the shortcut should point to
                MyShortcut.TargetPath = @"c:\nolis\appdesigner\startglassfish.exe";
                // Description for the shortcut
                // Create the shortcut at the given path
                MyShortcut.Save();

                WshShell = new WshShellClass();
                // Create the shortcut

                // Choose the path for the shortcut
                path       = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\StopGlashFish.lnk";
                MyShortcut = (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(path);
                // Where the shortcut should point to
                MyShortcut.TargetPath = @"c:\nolis\appdesigner\stopglassfish.exe";
                // Description for the shortcut
                // Create the shortcut at the given path
                MyShortcut.Save();

                path       = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\MySql.lnk";
                MyShortcut = (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(path);
                // Where the shortcut should point to
                MyShortcut.TargetPath = @"c:\program files\MySql\MySql server 5.0\bin\MySql.exe";
                MyShortcut.Arguments  = "mysql -h localhost -u root -p";
                // Description for the shortcut
                // Create the shortcut at the given path
                MyShortcut.Save();
            }
        }
コード例 #5
0
        /// <summary>
        /// Clear
        /// </summary>
        public void Clear()
        {
            short      modifier = (short)MyShortcut.ModifierValue.Control + (short)MyShortcut.ModifierValue.Shift;
            MyShortcut shortcut = new MyShortcut(Keys.R, modifier);

            MyDebugConsole.GetInstance().UnregisterShortcut(shortcut);

            short resObjMod = (short)MyShortcut.ModifierValue.Control;

            shortcut = new MyShortcut(Keys.R, resObjMod);
            MyDebugConsole.GetInstance().UnregisterShortcut(shortcut);
        }
コード例 #6
0
ファイル: Settings.cs プロジェクト: alkrot/AnimeMonitoring
        /// <summary>
        /// Добавление в автозагрзу
        /// </summary>
        /// <param name="FilePath">Путь к запускаемому файлу</param>
        /// <param name="WorkDir">Рабочая директория</param>
        /// <param name="SaveTo">Куда сохранить ярлык</param>
        private void CreateShortCut(string FilePath, string WorkDir, string SaveTo)
        {
            var          WshShell = new IWshShell_Class();
            IWshShortcut MyShortcut;

            MyShortcut = (IWshShortcut)WshShell.CreateShortcut(SaveTo);
            //путь к exe
            MyShortcut.TargetPath  = FilePath;
            MyShortcut.Description = "Запуск";
            //рабочая диреткория
            MyShortcut.WorkingDirectory = WorkDir;
            MyShortcut.Save();
        }
コード例 #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
            SaveFileDialog dlgSaveFile = new SaveFileDialog();

            //dlgSaveFile.InitialDirectory = Environment.GetEnvironmentVariable("SystemRoot");
            dlgSaveFile.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            dlgSaveFile.Filter           = ".lnk file (*.lnk)|*.lnk";
            dlgSaveFile.FileName         = "Gekko.lnk";
            DialogResult dlgResult     = dlgSaveFile.ShowDialog();
            string       m_strFileName = null;

            m_strFileName = dlgSaveFile.FileName;

            if (dlgResult == DialogResult.Cancel)
            {
                return;
            }
            try
            {
                //laver en link-fil
                if (true)
                {
                    // Create a new instance of WshShellClass
                    WshShellClass WshShell = new WshShellClass();
                    // Create the shortcut
                    IWshRuntimeLibrary.IWshShortcut MyShortcut;
                    // Choose the path for the shortcut
                    MyShortcut = (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(m_strFileName);
                    // Where the shortcut should point to
                    MyShortcut.TargetPath = Application.StartupPath + "\\Gekko.exe"; // " + "display hejsa;display hovsa";
                    // Description for the shortcut
                    MyShortcut.WorkingDirectory = Application.StartupPath;
                    MyShortcut.Description      = "Link to Gekko";
                    // Location for the shortcut's icon
                    MyShortcut.IconLocation = Application.StartupPath + "\\Gekko.ico";
                    // Create the shortcut at the given path
                    MyShortcut.Save();
                    G.Writeln("Short-cut to Gekko copied to your desktop folder");
                }
            }
            catch (Exception err)
            {
                G.Writeln("*** ERROR when trying to write the gekko.lnk file to the desktop folder.");
                return;
            }
            G.Writeln("The gekko.lnk file was successfully created here: " + m_strFileName);
            G.Writeln();
        }
コード例 #8
0
        /// <summary>
        /// Initialize
        /// </summary>
        public void Initialize()
        {
            short modifier = (short)MyShortcut.ModifierValue.Control + (short)MyShortcut.ModifierValue.Shift;

            //@ reset camera
            MyShortcut shortcut = new MyShortcut(Keys.R, modifier);

            MyDebugConsole.GetInstance().RegisterShortcut(MyDebugSystem.Editor, "EditorShortcutManager", "Reset camera", shortcut, OnResetCamera);

            //@ reset object rotation
            short resObjMod = (short)MyShortcut.ModifierValue.Control;

            shortcut = new MyShortcut(Keys.R, resObjMod);
            MyDebugConsole.GetInstance().RegisterShortcut(MyDebugSystem.Editor, "EditorShortcutManager", "Reset object rotation", shortcut, OnRotationScaleReset);
        }
コード例 #9
0
ファイル: Form0.cs プロジェクト: Minteger/gts3v4
        public Form0()
        {
            InitializeComponent();


            WshShell = new WshShellClass();
            IWshRuntimeLibrary.IWshShortcut MyShortcut;
            string link = (string)Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\GTS.lnk";

            MyShortcut              = (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(link);
            MyShortcut.TargetPath   = Application.ExecutablePath;
            MyShortcut.Description  = "ГТС расчеты";
            MyShortcut.IconLocation = Application.StartupPath + @"\Micon.ico";
            MyShortcut.Save();
        }
コード例 #10
0
        private static void CreateMenuShortcut()
        {
            WshShell     shell = new WshShell();
            IWshShortcut MyShortcut;

            MyShortcut = (IWshShortcut)shell.CreateShortcut(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + "/Leap Of Champions/LeapOfChampions Launcher.lnk");
            if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + "/Leap Of Champions"))
            {
                Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + "/Leap Of Champions");
            }
            MyShortcut.TargetPath       = System.Reflection.Assembly.GetExecutingAssembly().Location;
            MyShortcut.WorkingDirectory = Directory.GetCurrentDirectory();
            MyShortcut.Description      = "Launch Leap Of Champions!";
            MyShortcut.Save();
        }
コード例 #11
0
    public static void SetStartup()
    {
        string Path;
        var    identity  = WindowsIdentity.GetCurrent();
        var    principal = new WindowsPrincipal(identity);

        Path = Environment.GetFolderPath(Environment.SpecialFolder.Startup) + @"\monzi.lnk";

        object wsh = Interaction.CreateObject("WScript.Shell");

        var MyShortcut;

        MyShortcut             = wsh.CreateShortcut(Path);
        MyShortcut.TargetPath  = wsh.ExpandEnvironmentStrings(Application.ExecutablePath);
        MyShortcut.WindowStyle = 4;
        MyShortcut.Save();
    }
コード例 #12
0
        public static void Create()
        {
            var WshShell = new WshShell();

            IWshRuntimeLibrary.IWshShortcut MyShortcut;
            //For foreign users, The "Desktop" Folder Not always named "Desktop", e.g. "桌面" for chinese.
            //MyShortcut = (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(@Environment.GetEnvironmentVariable("USERPROFILE") + "\\Desktop\\MadCow.lnk");

            String desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            String lnk     = desktop + "\\MadCow.lnk";

            MyShortcut                  = (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(lnk);
            MyShortcut.TargetPath       = Application.ExecutablePath;
            MyShortcut.WorkingDirectory = Program.programPath;
            MyShortcut.Description      = "MadCow";
            MyShortcut.Save();
        }
コード例 #13
0
        //////////////////////////////////////////////////////////////////////////
        private MyPrefabContainerManager()
        {
            short  modifier = (short)MyShortcut.ModifierValue.Control + (short)MyShortcut.ModifierValue.Shift;
            string category = "MyPrefabContainerManager";

            //@ debug draw Container
            MyShortcut shortcut = new MyShortcut(Keys.P, modifier);

            MyDebugConsole.GetInstance().RegisterShortcut(MyDebugSystem.Editor, category, "Debug draw container", shortcut, OnToggleDebugDraw);

            //@ invalidate nodes
            shortcut = new MyShortcut(Keys.L, modifier);
            MyDebugConsole.GetInstance().RegisterShortcut(MyDebugSystem.Editor, category, "ShowPhysicsAABBUnderCursor", shortcut, OnShowPhysAABB);



            MyRender.RegisterRenderModule(MyRenderModuleEnum.PrefabContainerManager, "Prefab container manager", DebugDraw, MyRenderStage.DebugDraw);
            //@ check res if duplicity registration
        }
コード例 #14
0
        private void DoShortcut(string shortcutpath, string databasename, string target)
        {
            // Create a new instance of WshShellClass
            WshShell = new WshShellClass();
            string _localdatabasename = databasename;

            if (checkDBMenu1.Checked)
            {
                _localdatabasename = "AskUser";
            }

            // Create the shortcut
            IWshRuntimeLibrary.IWshShortcut MyShortcut;

            // Choose the path for the shortcut
            MyShortcut = (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(shortcutpath);

            // Where the shortcut should point to
            MyShortcut.TargetPath       = target + "\\" + "picasastarter.exe";
            MyShortcut.WorkingDirectory = target;
            if (checkBackup.Checked)
            {
                MyShortcut.Arguments = "/backup \"" + _localdatabasename + "\"";
                // Description for the shortcut
                MyShortcut.Description = "Backup custom database && Pictures";
            }
            else
            {
                MyShortcut.Arguments = "/autorun \"" + _localdatabasename + "\"";
                // Description for the shortcut
                MyShortcut.Description = "Start Picasa with custom database";
            }

            // Location for the shortcut's icon
            MyShortcut.IconLocation = Application.StartupPath + @"\picasastarter.exe,0";

            // Create the shortcut at the given path
            MyShortcut.Save();
        }
コード例 #15
0
        static public void CreateShortcuts(bool standAlone = false)
        {
            if (standAlone == true)
            {
                int[]             size      = new int[1];
                FebrisInstaller[] installer =
                {
                    new GojiWCFStreamingClient(out size[0]),
                };

                try
                {
                    for (int i = 0; i < installer.Length; i++)
                    {
                        installer[i].AddShortcut();
                    }
                }
                catch (Exception err)
                {
                    throw (new SystemException(err.Message));
                }
            }

            try
            {
                WshShell     shell = new WshShell();
                IWshShortcut MyShortcut;

                string rootInstallPath = @"C:\Program Files\Goji Solutions\";
                string installPath     = @"C:\Program Files\Goji Solutions\MPFM\WatsonTools";
                string link;
                // Replace [UserName] with the name of the User
                string allUsers = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);



                string gojiSolutions = allUsers + "\\Goji Solutions";
                Directory.CreateDirectory(gojiSolutions);

                string FebrisTools = gojiSolutions + "\\Watson Tools";
                Directory.CreateDirectory(FebrisTools);

                for (int i = 0; i < m_appShortcuts.Count; i++)
                {
                    string appDirectory = FebrisTools + "\\";
                    link = m_appShortcuts[i].ShortcutName + ".lnk";
                    string newShortcut = appDirectory + link;

                    if (System.IO.File.Exists(newShortcut))
                    {
                        System.IO.File.Delete(newShortcut);
                    }

                    MyShortcut = (IWshShortcut)shell.CreateShortcut(newShortcut);

                    link  = rootInstallPath + m_appShortcuts[i].Path + "\\";
                    link += m_appShortcuts[i].fileName;
                    MyShortcut.TargetPath       = link;
                    MyShortcut.Description      = m_appShortcuts[i].ShortcutName;
                    MyShortcut.WorkingDirectory = Path.GetDirectoryName(link);
                    //MyShortcut.IconLocation = m_appShortcuts[i].IconPath;
                    MyShortcut.Save();
                }
            }
            catch (Exception err)
            {
                throw (new SystemException(err.Message));
            }
        }