CygwinOpen() public static method

public static CygwinOpen ( string fileOrFolder ) : void
fileOrFolder string
return void
Ejemplo n.º 1
0
        public Form_TrayMenu()
        {
            //Check Arguments First -> Dont load GUI
            string[] args = Environment.GetCommandLineArgs();

            try
            {
                if (args[1] != null)
                {
                    Console.WriteLine("CommandLine Parameter 1: " + args[1]);
                    if (!args[1].StartsWith("-"))
                    {
                        Cygwin.CygwinOpen(args[1]);
                        Environment.Exit(-1);
                    }
                    else if (args[1].StartsWith("-uactask"))
                    {
                        ChangeRegistryPath.Change();
                        Environment.Exit(-1);
                    }
                    else
                    {
                        string path             = "";
                        string exitAfterExecute = "0";
                        int    idx = 0;

                        foreach (string arg in args)
                        {
                            if (args[idx] == "-path")
                            {
                                path = args[idx + 1];
                            }

                            if (args[idx] == "-wsl")
                            {
                                Globals.CurrentEnvironment = "wsl";
                            }

                            if (args[idx] == "-cygwin")
                            {
                                Globals.CurrentEnvironment = "cygwin";
                            }

                            if (args[idx] == "-exit")
                            {
                                if (args[idx + 1] != null)
                                {
                                    exitAfterExecute = args[idx + 1];
                                    Console.WriteLine("exitAfterExecute set to: " + exitAfterExecute);
                                }
                            }
                            idx = idx + 1;
                        }

                        if (exitAfterExecute == "1")
                        {
                            Globals.MainConfig["Cygwin"]["ExitAfterExec"] = true;
                        }


                        //MessageBox.Show("Test" + path, "Test", MessageBoxButtons.YesNo);
                        Cygwin.CygwinOpen(path);

                        Environment.Exit(-1);
                    }
                }
            }
            catch (IndexOutOfRangeException)
            {
                Console.WriteLine("Possible Commandline options: " + args[0] + " [-cygwin] [-wsl] [-path <PATH>] [-exit <0/1>]");
                Console.WriteLine("-path 'C:\\Windows' open Windows folder");
                Console.WriteLine("-exit 0 let the cygwin window open, -exit 1 close the cygwin window after execution");
                Console.WriteLine("");
                Console.WriteLine("Sample to open C:\\Windows Folder:");
                Console.WriteLine("   " + args[0] + " -path 'C:\\Windows'");
                Console.WriteLine("Sample to open Shellscript and dont close window after execution:");
                Console.WriteLine("   " + args[0] + " -path 'C:\\shellscript.sh' -exit 0");
                Console.WriteLine("Sample to open C:\\Windows Folder WITHOUT arguemnts:");
                Console.WriteLine("   " + args[0] + " 'C:\\Windows'");
                Console.WriteLine("Sample to open C:\\Windows Folder with cygwin:");
                Console.WriteLine("   " + args[0] + " -cygwin -path 'C:\\Windows'");
                Console.WriteLine("Sample to open C:\\Windows Folder with wsl:");
                Console.WriteLine("   " + args[0] + " -wsl -path 'C:\\Windows'");
            }

            ChangeRegistryPath.Change();
            //Check Arguments Ended -> If CygwinPortable still lives -> go on
            InitializeComponent();

            WindowState = FormWindowState.Minimized;
            if ((WindowState == FormWindowState.Minimized))
            {
                contextMenuStrip1.Show();
                Hide();
                ShowInTaskbar = false;
            }
        }
Ejemplo n.º 2
0
 private void CybeSystemsRunCygwin_Click(object sender, EventArgs e, string fileName)
 {
     Cygwin.CygwinOpen(fileName);
 }