Example #1
0
 static void Main(string[] Arguments)
 {
     if (mutex.WaitOne(TimeSpan.Zero, true))
     {
         AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
         PluginManager = new PluginManager();
         FileManager = new FileManager();
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         if (Arguments.Length > 0) Application.Run(new Form1(Arguments[0]));
         else Application.Run(new Form1());
     }
     else
     {
         String arg0 = "";
         if (Arguments.Length > 0) arg0 = Arguments[0];
         Win32Util.SendString((IntPtr)Win32Util.HWND_BROADCAST, arg0);
     }
 }
Example #2
0
        static void Main(string[] Arguments)
        {
            if (Arguments.Length > 0 && Arguments[0].EndsWith(".efesc"))
            {
                if (!Win32Util.AttachConsole(-1)) Win32Util.AllocConsole();
                AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
                PluginManager = new PluginManager();
                String Script = File.ReadAllText(Arguments[0]);
                string[] args = new string[Arguments.Length - 1];
                Array.Copy(Arguments, 1, args, 0, args.Length);
                Console.WriteLine();
                Console.WriteLine("Executing " + Path.GetFileName(Arguments[0]) + "...");
                EFEScript.Execute(Script, args);
                Win32Util.FreeConsole();
                //Using this causes scripts to be runned over and over again if opened by double-clicking
                //But without this, you need to press ENTER before be able to use the cmd again if you run it from there...
                //SendKeys.SendWait("{ENTER}");
                return;
            }

            if (mutex.WaitOne(TimeSpan.Zero, true))
            {
                AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
                PluginManager = new PluginManager();
                FileManager = new FileManager();
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                if (Arguments.Length > 0) Application.Run(new Form1(Arguments[0]));
                else Application.Run(new Form1());
            }
            else
            {
                String arg0 = "";
                if (Arguments.Length > 0) arg0 = Arguments[0];
                foreach (var p in System.Diagnostics.Process.GetProcessesByName(System.Diagnostics.Process.GetCurrentProcess().ProcessName))
                {
                    if (p != System.Diagnostics.Process.GetCurrentProcess()) Win32Util.SendString(/*(IntPtr)Win32Util.HWND_BROADCAST*/p.MainWindowHandle, arg0);
                }
            }
        }