Esempio n. 1
0
        static void StartApp(string[] args)
        {
            if (!RuntimePolicyHelper.LegacyV2RuntimeEnabledSuccessfully)
            {
                // Failed to enable useLegacyV2RuntimeActivationPolicy at runtime.
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            // Requires System.Configuration.Installl reference.
            var ic = new System.Configuration.Install.InstallContext(null, args);

            if (ic.Parameters.ContainsKey("Settings"))
            {
                OpenSettingsFolder(Application.UserAppDataPath);
                OpenSettingsFolder(Application.CommonAppDataPath);
                OpenSettingsFolder(Application.LocalUserAppDataPath);
                return;
            }
            if (!CheckSettings())
            {
                return;
            }
            //Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            MainForm.Current = new MainForm();
            if (ic.Parameters.ContainsKey("Exit"))
            {
                MainForm.Current.BroadcastMessage(MainForm.wParam_Close);
                return;
            }
            if (!IsOneCopyRunningAlready())
            {
                Application.Run(MainForm.Current);
            }
        }
Esempio n. 2
0
 static void Main(string[] args)
 {
     System.Configuration.Install.InstallContext _args = new System.Configuration.Install.InstallContext(null, args);
     if (_args.IsParameterTrue("start-service"))
     {
         bool own = false;
         System.Threading.EventWaitHandle evt = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.AutoReset, NAME, out own);
         if (own)
         {
             // download db
             //Task.Run(() => download_imei2model());
             start(evt);
         }
         else
         {
             // already running.
         }
     }
     else if (_args.IsParameterTrue("kill-service"))
     {
         try
         {
             System.Threading.EventWaitHandle evt = System.Threading.EventWaitHandle.OpenExisting(NAME);
             evt.Set();
         }
         catch (Exception) { }
     }
     else
     {
     }
 }
Esempio n. 3
0
        // Application starts first time.
        private static void App_Startup(object sender, StartupEventArgs e)
        {
            var o    = SettingsManager.Options;
            var args = System.Environment.GetCommandLineArgs();
            var ic   = new System.Configuration.Install.InstallContext(null, args);

            // If windows state parameter was passed then...
            if (ic.Parameters.ContainsKey(arg_WindowState))
            {
                switch (ic.Parameters[arg_WindowState])
                {
                case nameof(WindowState.Maximized):
                    Global._TrayManager.RestoreFromTray(false, true);
                    break;

                case nameof(WindowState.Minimized):
                    Global._TrayManager.MinimizeToTray(false, o.MinimizeToTray);
                    break;
                }
            }
            else
            {
                //Global._TrayManager.RestoreFromTray(false, false);
            }
        }
Esempio n. 4
0
 static void Main(string[] args)
 {
     System.Configuration.Install.InstallContext _args = new System.Configuration.Install.InstallContext(null, args);
     if (_args.IsParameterTrue("debug"))
     {
         System.Console.WriteLine("Wait for debugger, press any key to continue");
         System.Console.ReadKey();
     }
     if (_args.IsParameterTrue("train"))
     {
         // train process
         train(_args.Parameters);
     }
     else if (_args.IsParameterTrue("sample"))
     {
         sample_device(_args.Parameters);
     }
     else if (_args.IsParameterTrue("predict"))
     {
         check_device_color(_args.Parameters);
     }
     else
     {
         //test();
         test_svm();
         //sample_device(_args.Parameters);
         //test_knn();
     }
 }
 public AppConfigModifier(System.Configuration.Install.InstallContext context)
 {
     formContext = context;
     InitializeComponent();
     chkBox.Checked = false;
     this.CenterToParent();
 }
 public SelectPowerTools(System.Configuration.Install.InstallContext context)
 {
     formContext = context;
     InitializeComponent();
     this.CenterToScreen();
     
 }
Esempio n. 7
0
        static bool ProcessAdminCommands(string[] args)
        {
            // Requires System.Configuration.Installl reference.
            var ic = new System.Configuration.Install.InstallContext(null, args);

            // ------------------------------------------------
            // Virtual Drivers
            // ------------------------------------------------
            if (ic.Parameters.ContainsKey(AdminCommand.InstallViGEmBus.ToString()))
            {
                DInput.VirtualDriverInstaller.InstallViGEmBus();
                return(true);
            }
            if (ic.Parameters.ContainsKey(AdminCommand.UninstallViGEmBus.ToString()))
            {
                DInput.VirtualDriverInstaller.UninstallViGEmBus();
                return(true);
            }
            if (ic.Parameters.ContainsKey(AdminCommand.InstallHidGuardian.ToString()))
            {
                DInput.VirtualDriverInstaller.InstallHidGuardian();
                return(true);
            }
            if (ic.Parameters.ContainsKey(AdminCommand.UninstallHidGuardian.ToString()))
            {
                DInput.VirtualDriverInstaller.UninstallHidGuardian();
                return(true);
            }
            return(false);
        }
Esempio n. 8
0
        private System.Configuration.Install.InstallContext getContext(String action)
        {
            System.Configuration.Install.InstallContext context = new System.Configuration.Install.InstallContext();
            String servicePath = String.Format("/assemblypath={0}", getPath());

            String[] cmdline = { servicePath };
            context = new System.Configuration.Install.InstallContext(action, cmdline);
            return(context);
        }
Esempio n. 9
0
        public void Uninstall(string ServiceName)
        {
            System.ServiceProcess.ServiceInstaller SINST = new System.ServiceProcess.ServiceInstaller();

            System.Configuration.Install.InstallContext Context = new System.Configuration.Install.InstallContext();
            SINST.Context     = Context;
            SINST.ServiceName = string.Format("{0}", ServiceName);
            SINST.Uninstall(null);
        }
Esempio n. 10
0
        public void Uninstall(String ServiceName)
        {
            System.ServiceProcess.ServiceInstaller SINST = new System.ServiceProcess.ServiceInstaller();

            System.Configuration.Install.InstallContext Context = new System.Configuration.Install.InstallContext("c:\\install.log", null);
            SINST.Context     = Context;
            SINST.ServiceName = ServiceName;
            SINST.Uninstall(null);
        }
Esempio n. 11
0
        static void Main(string[] args)
        {
            // try
            // {
            // IMPORTANT: Make sure this method don't have any static references to x360ce.Engine librarry or
            // program tries to load x360ce.Engine.dll before AssemblyResolve event is available and fails.
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
            if (!RuntimePolicyHelper.LegacyV2RuntimeEnabledSuccessfully)
            {
                // Failed to enable useLegacyV2RuntimeActivationPolicy at runtime.
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            // Requires System.Configuration.Installl reference.
            var ic = new System.Configuration.Install.InstallContext(null, args);

            if (ic.Parameters.ContainsKey("Settings"))
            {
                OpenSettingsFolder(Application.UserAppDataPath);
                OpenSettingsFolder(Application.CommonAppDataPath);
                OpenSettingsFolder(Application.LocalUserAppDataPath);
                return;
            }
            if (!CheckSettings())
            {
                return;
            }
            //Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            MainForm.Current = new MainForm();
            if (ic.Parameters.ContainsKey("Exit"))
            {
                MainForm.Current.BroadcastMessage(MainForm.wParam_Close);
                return;
            }
            if (!IsOneCopyRunningAlready())
            {
                Application.Run(MainForm.Current);
            }
            // }
            //catch (Exception ex)
            //{
            //	var message = "";
            //	AddExceptionMessage(ex, ref message);
            //	if (ex.InnerException != null) AddExceptionMessage(ex.InnerException, ref message);
            //	var box = new Controls.MessageBoxForm();
            //	if (message.Contains("Could not load file or assembly 'Microsoft.DirectX"))
            //	{
            //		message += "===============================================================\r\n";
            //		message += "You can click the link below to download Microsoft DirectX.";
            //		box.MainLinkLabel.Text = "http://www.microsoft.com/en-us/download/details.aspx?id=35";
            //		box.MainLinkLabel.Visible = true;
            //	}
            //	var result = box.ShowForm(message, "Exception!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            //	if (result == DialogResult.Cancel) Application.Exit();
            //}
        }
Esempio n. 12
0
        static void StartApp(string[] args)
        {
            //var fi = new FileInfo(Application.ExecutablePath);
            //Directory.SetCurrentDirectory(fi.Directory.FullName);
            // IMPORTANT: Make sure this method don't have any static references to x360ce.Engine library or
            // program tries to load x360ce.Engine.dll before AssemblyResolve event is available and fails.
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
            if (!RuntimePolicyHelper.LegacyV2RuntimeEnabledSuccessfully)
            {
                // Failed to enable useLegacyV2RuntimeActivationPolicy at runtime.
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            // Requires System.Configuration.Installl reference.
            var ic = new System.Configuration.Install.InstallContext(null, args);
            // ------------------------------------------------
            // Administrator commands.
            // ------------------------------------------------
            var executed = ProcessAdminCommands(false, args);

            // If valid command was executed then...
            if (executed)
            {
                return;
            }
            // ------------------------------------------------
            if (ic.Parameters.ContainsKey("Settings"))
            {
                OpenSettingsFolder(Application.UserAppDataPath);
                OpenSettingsFolder(Application.CommonAppDataPath);
                OpenSettingsFolder(Application.LocalUserAppDataPath);
                return;
            }
            if (!CheckSettings())
            {
                return;
            }
            MainForm.Current = new MainForm();
            if (ic.Parameters.ContainsKey("Exit"))
            {
                MainForm.Current.BroadcastMessage(MainForm.wParam_Close);
                return;
            }
            var doNotAllowToRun = SettingsManager.Options.AllowOnlyOneCopy && MainForm.Current.BroadcastMessage(MainForm.wParam_Restore);

            // If one copy is already opened then...
            if (doNotAllowToRun)
            {
                // Dispose properly so that the tray icon will be removed.
                MainForm.Current.Dispose();
            }
            else
            {
                Application.Run(MainForm.Current);
            }
        }
Esempio n. 13
0
        public static void Uninstall(String ServiceName)
        {
            //http://www.theblacksparrow.com/
            System.ServiceProcess.ServiceInstaller SINST = new System.ServiceProcess.ServiceInstaller();

            System.Configuration.Install.InstallContext Context = new System.Configuration.Install.InstallContext("c:\\install.log", null);
            SINST.Context     = Context;
            SINST.ServiceName = ServiceName;
            SINST.Uninstall(null);
        }
Esempio n. 14
0
        public void Uninstall(String ServiceName, String InstanceID)
        {
            //http://www.theblacksparrow.com/
            System.ServiceProcess.ServiceInstaller SINST = new System.ServiceProcess.ServiceInstaller();

            System.Configuration.Install.InstallContext Context = new System.Configuration.Install.InstallContext("c:\\install.log", null);
            SINST.Context     = Context;
            SINST.ServiceName = String.Format("{0}_{1}", ServiceName, InstanceID);
            SINST.Uninstall(null);
        }
Esempio n. 15
0
        public FrmStatus(System.Configuration.Install.InstallContext context,
                         string barTitle, string headTitle, DelExecute method)
        {
            formContext = context;
            InitializeComponent();
            this.CenterToScreen();

            this.Text          = barTitle;
            this.LabelMsg.Text = headTitle;
            this.delHandler    = method;
        }
Esempio n. 16
0
        public FrmStatus(System.Configuration.Install.InstallContext context,
            string barTitle, string headTitle, DelExecute method)
        {
            formContext = context;
            InitializeComponent();
            this.CenterToScreen();

            this.Text = barTitle;
            this.LabelMsg.Text = headTitle;
            this.delHandler = method;
        }
Esempio n. 17
0
		static void Main(string[] args)
		{
			try
			{
				//var fi = new FileInfo(Application.ExecutablePath);
				//Directory.SetCurrentDirectory(fi.Directory.FullName);
				// IMPORTANT: Make sure this method don't have any static references to x360ce.Engine library or
				// program tries to load x360ce.Engine.dll before AssemblyResolve event is available and fails.
				AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
				if (!RuntimePolicyHelper.LegacyV2RuntimeEnabledSuccessfully)
				{
					// Failed to enable useLegacyV2RuntimeActivationPolicy at runtime.
				}
				Application.EnableVisualStyles();
				Application.SetCompatibleTextRenderingDefault(false);
				// Requires System.Configuration.Installl reference.
				var ic = new System.Configuration.Install.InstallContext(null, args);
				if (ic.Parameters.ContainsKey("Settings"))
				{
					OpenSettingsFolder(Application.UserAppDataPath);
					OpenSettingsFolder(Application.CommonAppDataPath);
					OpenSettingsFolder(Application.LocalUserAppDataPath);
					return;
				}
				if (!CheckSettings()) return;
				//Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
				MainForm.Current = new MainForm();
				if (ic.Parameters.ContainsKey("Exit"))
				{
					MainForm.Current.BroadcastMessage(MainForm.wParam_Close);
					return;
				}
				if (!IsOneCopyRunningAlready())
				{
					Application.Run(MainForm.Current);
				}
			}
			catch (Exception ex)
			{
				var message = "";
				AddExceptionMessage(ex, ref message);
				if (ex.InnerException != null) AddExceptionMessage(ex.InnerException, ref message);
				var box = new Controls.MessageBoxForm();
				if (message.Contains("Could not load file or assembly 'Microsoft.DirectX"))
				{
					message += "===============================================================\r\n";
					message += "You can click the link below to download Microsoft DirectX.";
					box.MainLinkLabel.Text = "http://www.microsoft.com/en-us/download/details.aspx?id=35";
					box.MainLinkLabel.Visible = true;
				}
				var result = box.ShowForm(message, "Exception!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
				if (result == DialogResult.Cancel) Application.Exit();
			}
		}
Esempio n. 18
0
        public void Install(String ServiceName, String DisplayName, String Description,
                            System.ServiceProcess.ServiceAccount Account,
                            System.ServiceProcess.ServiceStartMode StartMode)
        {
            System.ServiceProcess.ServiceProcessInstaller ProcessInstaller = new System.ServiceProcess.ServiceProcessInstaller();
            ProcessInstaller.Account = Account;

            System.ServiceProcess.ServiceInstaller SINST = new System.ServiceProcess.ServiceInstaller();

            System.Configuration.Install.InstallContext Context = new System.Configuration.Install.InstallContext();
            string processPath = Process.GetCurrentProcess().MainModule.FileName;

            if (processPath != null && processPath.Length > 0)
            {
                System.IO.FileInfo fi = new System.IO.FileInfo(processPath);
                //Context = new System.Configuration.Install.InstallContext();
                //Context.Parameters.Add("assemblyPath", fi.FullName);
                //Context.Parameters.Add("startParameters", "Test");

                String   path    = String.Format("/assemblypath={0}", fi.FullName);
                String[] cmdline = { path };
                Context = new System.Configuration.Install.InstallContext("", cmdline);
            }

            SINST.Context     = Context;
            SINST.DisplayName = DisplayName;
            SINST.Description = Description;
            SINST.ServiceName = ServiceName;
            SINST.StartType   = StartMode;
            SINST.Parent      = ProcessInstaller;

            // http://bytes.com/forum/thread527221.html
            //            SINST.ServicesDependedOn = new String[] {};

            System.Collections.Specialized.ListDictionary state = new System.Collections.Specialized.ListDictionary();
            SINST.Install(state);

            // http://www.dotnet247.com/247reference/msgs/43/219565.aspx
            using (RegistryKey oKey = Registry.LocalMachine.OpenSubKey(String.Format(@"SYSTEM\CurrentControlSet\Services\{0}", SINST.ServiceName), true))
            {
                try
                {
                    Object sValue = oKey.GetValue("ImagePath");
                    oKey.SetValue("ImagePath", sValue);
                }
                catch (Exception Ex)
                {
                    //                    System.Console.WriteLine(Ex.Message);
                }
            }
        }
Esempio n. 19
0
        void Install(String ServiceName, String DisplayName, String Description,
                     System.ServiceProcess.ServiceAccount Account,
                     System.ServiceProcess.ServiceStartMode StartMode)
        {
            System.ServiceProcess.ServiceProcessInstaller ProcessInstaller = new System.ServiceProcess.ServiceProcessInstaller();
            ProcessInstaller.Account = Account;

            System.ServiceProcess.ServiceInstaller SINST = new System.ServiceProcess.ServiceInstaller();

            System.Configuration.Install.InstallContext Context = new System.Configuration.Install.InstallContext();
            string processPath = Process.GetCurrentProcess().MainModule.FileName;

            if (processPath != null && processPath.Length > 0)
            {
                System.IO.FileInfo fi = new System.IO.FileInfo(processPath);

                String   path    = String.Format("/assemblypath={0}", fi.FullName);
                String[] cmdline = { path };
                Context = new System.Configuration.Install.InstallContext("", cmdline);
            }

            SINST.Context     = Context;
            SINST.DisplayName = String.Format("{0}", DisplayName);
            SINST.Description = String.Format("{0}", Description);
            SINST.ServiceName = String.Format("{0}", ServiceName);
            SINST.StartType   = StartMode;
            SINST.Parent      = ProcessInstaller;

            //          SINST.ServicesDependedOn = new String[] { "Spooler", "Netlogon", "Netman" };
            SINST.ServicesDependedOn = null;

            System.Collections.Specialized.ListDictionary state = new System.Collections.Specialized.ListDictionary();
            SINST.Install(state);

            using (RegistryKey oKey = Registry.LocalMachine.OpenSubKey(String.Format(@"SYSTEM\CurrentControlSet\Services\{0}", ServiceName), true))
            {
                try
                {
                    //                  Object sValue = oKey.GetValue("ImagePath");
                    Object sValue = oKey.GetValue("ImagePath");
                    string str    = string.Format("{0} service", sValue.ToString());
                    oKey.SetValue("ImagePath", str);
                }
                catch (Exception Ex)
                {
                    // System.Windows.Forms.MessageBox.Show(Ex.Message);
                    System.Console.WriteLine("Failed to install {0}", Ex.Message);
                }
            }
        }
Esempio n. 20
0
 static int Main(string [] args)
 {
     System.Configuration.Install.InstallContext _args = new System.Configuration.Install.InstallContext(null, args);
     if (_args.IsParameterTrue("debug"))
     {
         MessageBox.Show("wait for debug");
     }
     Program.args = _args.Parameters;
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new Form1());
     //Application.Run(new FormTest());
     return(exit_code);
 }
Esempio n. 21
0
        static bool ProcessAdminCommands(bool direct, string[] args)
        {
            // Requires System.Configuration.Installl reference.
            var ic = new System.Configuration.Install.InstallContext(null, args);

            if (ic.Parameters.ContainsKey(AdminCommand.FixProgramSettingsPermissions.ToString()))
            {
                var path   = SettingsFile.Current.FolderPath;
                var rights = FileSystemRights.Write | FileSystemRights.Modify;
                var users  = new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null);
                JocysCom.ClassLibrary.Security.PermissionHelper.SetRights(path, rights, users);
                return(true);
            }
            return(false);
        }
Esempio n. 22
0
        public void Uninstall(String ServiceName, String InstanceID)
        {
            System.ServiceProcess.ServiceInstaller SINST = new System.ServiceProcess.ServiceInstaller();

            System.Configuration.Install.InstallContext Context = new System.Configuration.Install.InstallContext("c:\\install.log", null);
            SINST.Context = Context;
            if (!string.IsNullOrEmpty(InstanceID))
            {
                SINST.ServiceName = String.Format("{0}_{1}", ServiceName, InstanceID);
            }
            else
            {
                SINST.ServiceName = ServiceName;
            }
            SINST.Uninstall(null);
        }
Esempio n. 23
0
 static void Main(string[] args)
 {
     System.Configuration.Install.InstallContext _args = new System.Configuration.Install.InstallContext(null, args);
     if (_args.Parameters.ContainsKey("udid"))
     {
         bool   bFind = false;
         String suid  = _args.Parameters["udid"];
         if (!String.IsNullOrEmpty(suid) && suid.Length == 40)
         {
             Console.WriteLine(suid + "=" + suid);
             return;
         }
         List <String> sdevs = GetListDevices();
         foreach (String s in sdevs)
         {
             String ssss     = suid;
             String listudid = s;
             //if(String.Compare(suid,s, true)==0)
             //{
             //    Console.WriteLine(suid+"="+s);
             //    bFind = true;
             //    break;
             //}
             //else
             if (String.Compare(ssss.Replace("-", ""), s.Replace("-", ""), true) == 0)
             {
                 Console.WriteLine(suid + "=" + listudid);
                 bFind = true;
                 break;
             }
         }
         if (!bFind)
         {//00008020-001974103C50003A
             String studid = suid;
             if (studid.Length == 24)
             {
                 studid = studid.Insert(8, "-");
             }
             Console.WriteLine(suid + "=" + studid);
         }
     }
     else
     {
         Console.WriteLine("-udid=XXXX");
     }
 }
Esempio n. 24
0
        public static void Install(String ServiceName, String DisplayName, String Description, String exeName,
                                   System.ServiceProcess.ServiceAccount Account,
                                   System.ServiceProcess.ServiceStartMode StartMode)
        {
            //http://www.theblacksparrow.com/
            System.ServiceProcess.ServiceProcessInstaller ProcessInstaller = new System.ServiceProcess.ServiceProcessInstaller();
            ProcessInstaller.Account = Account;

            System.ServiceProcess.ServiceInstaller SINST = new System.ServiceProcess.ServiceInstaller();

            System.Configuration.Install.InstallContext Context = new System.Configuration.Install.InstallContext();
            System.IO.FileInfo fi = new System.IO.FileInfo(exeName);

            String path = String.Format("/assemblypath={0}", fi.FullName);

            String[] cmdline = { path };
            Context = new System.Configuration.Install.InstallContext("", cmdline);

            SINST.Context     = Context;
            SINST.DisplayName = DisplayName;
            SINST.Description = Description;
            SINST.ServiceName = ServiceName;
            SINST.StartType   = StartMode;
            SINST.Parent      = ProcessInstaller;

            // http://bytes.com/forum/thread527221.html
            //SINST.ServicesDependedOn = new String[] { "Spooler", "Netlogon", "Netman" };
            SINST.ServicesDependedOn = new String[] { };

            System.Collections.Specialized.ListDictionary state = new System.Collections.Specialized.ListDictionary();
            SINST.Install(state);

            // http://www.dotnet247.com/247reference/msgs/43/219565.aspx
            using (RegistryKey oKey = Registry.LocalMachine.OpenSubKey(String.Format(@"SYSTEM\CurrentControlSet\Services\{0}", ServiceName), true))
            {
                try
                {
                    Object sValue = oKey.GetValue("ImagePath");
                    oKey.SetValue("ImagePath", sValue);
                }
                catch (Exception Ex)
                {
                    System.Windows.Forms.MessageBox.Show(Ex.Message);
                }
            }
        }
Esempio n. 25
0
        public void Install(string ServiceName, string DisplayName, string Description,
                            string InstanceID, System.ServiceProcess.ServiceAccount Account, System.ServiceProcess.ServiceStartMode StartMode)
        {
            System.ServiceProcess.ServiceProcessInstaller ProcessInstaller = new System.ServiceProcess.ServiceProcessInstaller();
            ProcessInstaller.Account = Account;

            System.ServiceProcess.ServiceInstaller SINST = new System.ServiceProcess.ServiceInstaller();

            System.Configuration.Install.InstallContext Context = new System.Configuration.Install.InstallContext();
            string processPath = Process.GetCurrentProcess().MainModule.FileName;

            if (processPath != null && processPath.Length > 0)
            {
                System.IO.FileInfo fi = new System.IO.FileInfo(processPath);

                string   path    = string.Format("/assemblypath={0}", fi.FullName);
                string[] cmdline = { path };
                Context = new System.Configuration.Install.InstallContext("", cmdline);
            }

            SINST.Context     = Context;
            SINST.DisplayName = string.Format("{0} - {1}", DisplayName, InstanceID);
            SINST.Description = string.Format("{0} - {1}", Description, InstanceID);
            SINST.ServiceName = string.Format("{0}_{1}", ServiceName, InstanceID);
            SINST.StartType   = StartMode;
            SINST.Parent      = ProcessInstaller;

            SINST.ServicesDependedOn = new string[] { "RpcSs" };

            System.Collections.Specialized.ListDictionary state = new System.Collections.Specialized.ListDictionary();
            SINST.Install(state);

            using (RegistryKey oKey = Registry.LocalMachine.OpenSubKey(string.Format(@"SYSTEM\CurrentControlSet\Services\{0}_{1}", ServiceName, InstanceID), true))
            {
                try
                {
                    Object sValue = oKey.GetValue("ImagePath");
                    oKey.SetValue("ImagePath", sValue);
                }
                catch (Exception Ex)
                {
                    Trace.TraceError(Ex.Message);
                }
            }
        }
Esempio n. 26
0
        private void UnregisterService()
        {
            Logger.Write("Will try to Unregister : " + ServiceName);
            try
            {
                ServiceInstaller ServiceInstallerObj = new ServiceInstaller();
                System.Configuration.Install.InstallContext Context = new System.Configuration.Install.InstallContext();
                ServiceInstallerObj.Context     = Context;
                ServiceInstallerObj.ServiceName = ServiceName;
                ServiceInstallerObj.Uninstall(null);

                Logger.Write("Successfully Unregister " + ServiceName);
            }
            catch (Exception ex)
            {
                Logger.Write("Failed to Unregister " + ServiceName + "\r\n" + ex.Message);
            }
        }
Esempio n. 27
0
        static int Main(string[] args)
        {
            int ret = -1;

            System.Configuration.Install.InstallContext _args = new System.Configuration.Install.InstallContext(null, args);
            if (_args.IsParameterTrue("debug"))
            {
                Console.WriteLine("Wait for debugger, press any key to continue.");
                Console.ReadKey();
            }
            if (_args.IsParameterTrue("transaction"))
            {
                ret = CmcClient.sendTransaction_BZ(_args.Parameters);
                //ret = CmcClient.sendTransaction(_args.Parameters);
                //ret = CmcClient.sendTransactionToVerizon(_args.Parameters);
            }
            else if (_args.IsParameterTrue("login"))
            {
                ret = CmcClient.cmc_login(_args.Parameters);
            }
            else if (_args.IsParameterTrue("prepareEnv"))
            {
                ret = PrepareEnv.startup(_args.Parameters);
            }
            else if (_args.IsParameterTrue("cleanEnv"))
            {
                //ret = PrepareEnv.startup(_args.Parameters);
            }
            else if (_args.IsParameterTrue("oecontrol"))
            {
                //OEControl.OE_App_3_0_2_0();
                //OEControl.startup(_args.Parameters);
                OEControl.start(_args.Parameters);
            }
            else
            {
                test();
                //OEControl.start();
            }

            return(ret);
        }
Esempio n. 28
0
 static void Main(string[] args)
 {
     System.Configuration.Install.InstallContext _args = new System.Configuration.Install.InstallContext(null, args);
     if (_args.IsParameterTrue("debug"))
     {
         System.Console.WriteLine("wait for debugger, press any key.");
         System.Console.ReadKey();
     }
     if (_args.Parameters.ContainsKey("test"))
     {
         test(_args.Parameters);
     }
     else
     {
         if (_args.Parameters.ContainsKey("xml"))
         {
             train(_args.Parameters);
         }
     }
 }
        public override void Run(ref ReturnCodeAction returnCode)
        {
            Logger.Write("Running UnregisterServiceAction.");

            try
            {
                ServiceInstaller ServiceInstallerObj = new ServiceInstaller();
                System.Configuration.Install.InstallContext Context = new System.Configuration.Install.InstallContext();
                ServiceInstallerObj.Context     = Context;
                ServiceInstallerObj.ServiceName = ServiceName;
                ServiceInstallerObj.Uninstall(null);

                Logger.Write("Service successfully unregistered.");
            }
            catch (Exception ex)
            {
                Logger.Write("**** An error occurs : " + ex.Message);
            }

            Logger.Write("End of UnregisterServiceAction.");
        }
Esempio n. 30
0
        static void StartApp(string[] args)
        {
            //var fi = new FileInfo(Application.ExecutablePath);
            //Directory.SetCurrentDirectory(fi.Directory.FullName);
            // IMPORTANT: Make sure this method don't have any static references to x360ce.Engine library or
            // program tries to load x360ce.Engine.dll before AssemblyResolve event is available and fails.
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
            if (!RuntimePolicyHelper.LegacyV2RuntimeEnabledSuccessfully)
            {
                // Failed to enable useLegacyV2RuntimeActivationPolicy at runtime.
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            // Requires System.Configuration.Installl reference.
            var ic = new System.Configuration.Install.InstallContext(null, args);

            if (ic.Parameters.ContainsKey("Settings"))
            {
                OpenSettingsFolder(Application.UserAppDataPath);
                OpenSettingsFolder(Application.CommonAppDataPath);
                OpenSettingsFolder(Application.LocalUserAppDataPath);
                return;
            }
            if (!CheckSettings())
            {
                return;
            }
            //Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            Application.ApplicationExit += Application_ApplicationExit;
            MainForm.Current             = new MainForm();
            if (ic.Parameters.ContainsKey("Exit"))
            {
                MainForm.Current.BroadcastMessage(MainForm.wParam_Close);
                return;
            }
            if (!IsOneCopyRunningAlready())
            {
                Application.Run(MainForm.Current);
            }
        }
Esempio n. 31
0
 static void Main(string[] args)
 {
     System.Configuration.Install.InstallContext _args = new System.Configuration.Install.InstallContext(null, args);
     if (_args.IsParameterTrue("debug"))
     {
         System.Console.WriteLine("Wait for debugger, press any key to continue");
         System.Console.ReadKey();
     }
     if (_args.IsParameterTrue("train"))
     {
         if (_args.Parameters.ContainsKey("file") && System.IO.File.Exists(_args.Parameters["file"]))
         {
             //train(_args.Parameters["file"]);
             train_knn(_args.Parameters["file"]);
             test(@"C:\projects\local\GradeChecker\GradeChecker\bin\Debug\test_data.json");
         }
     }
     else
     {
         //train();
         test(@"C:\projects\local\GradeChecker\GradeChecker\bin\Debug\test_data.json");
     }
 }
Esempio n. 32
0
        static int Main(string[] args)
        {
            int ret = -1;

            System.Configuration.Install.InstallContext _args = new System.Configuration.Install.InstallContext(null, args);
            if (_args.IsParameterTrue("debug"))
            {
                System.Console.WriteLine("Press any key to continue.");
                System.Console.ReadKey();
            }
            string adb = "";

            if (_args.Parameters.ContainsKey("adb"))
            {
                if (System.IO.File.Exists(_args.Parameters["adb"]))
                {
                    adb = _args.Parameters["adb"];
                }
            }
            if (string.IsNullOrEmpty(adb))
            {
                // search for adb.exe
                ret = 1;
            }
            else
            {
                logIt($"adb = {adb}");
                string sn = "";
                if (_args.Parameters.ContainsKey("sn"))
                {
                    sn = _args.Parameters["sn"];
                    logIt($"adb = {adb}");
                }
                ret = start(adb, sn);
            }
            return(ret);
        }
Esempio n. 33
0
        static void Main1(string[] args)
        {
            System.Configuration.Install.InstallContext _args = new System.Configuration.Install.InstallContext(null, args);
            if (_args.IsParameterTrue("debug"))
            {
                System.Console.WriteLine("Wait for debugger, press any key to continue...");
                System.Console.ReadKey();
            }

            System.Net.HttpListener listener = new System.Net.HttpListener();
            listener.Prefixes.Add("http://+:80/");
            listener.Start();
            listener.BeginGetContext(new AsyncCallback(httpListenerCallback), listener);
            bool quit = false;

            System.Console.WriteLine("Http starts, press x to terminate...");
            while (!quit)
            {
                if (System.Console.KeyAvailable)
                {
                    System.ConsoleKeyInfo k = System.Console.ReadKey();
                    if (k.KeyChar == 'x')
                    {
                        quit = true;
                    }
                }
                if (!quit)
                {
                    System.Threading.Thread.Sleep(1000);
                }
            }
            if (listener.IsListening)
            {
                listener.Stop();
            }
            listener.Close();
        }
Esempio n. 34
0
 private void button_uninstall_dp2library_Click(object sender, EventArgs e)
 {
     System.ServiceProcess.ServiceInstaller installer = new System.ServiceProcess.ServiceInstaller();
     System.Configuration.Install.InstallContext context = new System.Configuration.Install.InstallContext();
     installer.Context = context;
     installer.ServiceName = "dp2LibraryService";
     try
     {
         installer.Uninstall(null);
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ExceptionUtil.GetAutoText(ex));
     }
 }
Esempio n. 35
0
 static void Main(string[] args)
 {
     try
     {
         AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
         if (!RuntimePolicyHelper.LegacyV2RuntimeEnabledSuccessfully)
         {
             // Failed to enable useLegacyV2RuntimeActivationPolicy at runtime.
         }
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         // Requires System.Configuration.Installl reference.
         var ic = new System.Configuration.Install.InstallContext(null, args);
         if (ic.Parameters.ContainsKey("Settings"))
         {
             OpenSettingsFolder(Application.UserAppDataPath);
             OpenSettingsFolder(Application.CommonAppDataPath);
             OpenSettingsFolder(Application.LocalUserAppDataPath);
             return;
         }
         if (!CheckSettings()) return;
         //Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
         MainForm.Current = new MainForm();
         if (ic.Parameters.ContainsKey("Exit"))
         {
             MainForm.Current.BroadcastMessage(MainForm.wParam_Close);
             return;
         }
         var ini = new Ini(SettingManager.IniFileName);
         var oneCopy = !ini.File.Exists || ini.GetValue("Options", SettingName.AllowOnlyOneCopy) == "1";
         if (!(oneCopy && MainForm.Current.BroadcastMessage(MainForm.wParam_Restore)))
         {
             Application.Run(MainForm.Current);
         }
     }
     catch (Exception ex)
     {
         var message = "";
         AddExceptionMessage(ex, ref message);
         if (ex.InnerException != null) AddExceptionMessage(ex.InnerException, ref message);
         var box = new Controls.MessageBoxForm();
         if (message.Contains("Could not load file or assembly 'Microsoft.DirectX"))
         {
             message += "===============================================================\r\n";
             message += "You can click the link below to download Microsoft DirectX.";
             box.MainLinkLabel.Text = "http://www.microsoft.com/en-us/download/details.aspx?id=35";
             box.MainLinkLabel.Visible = true;
         }
         var result = box.ShowForm(message, "Exception!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
         if (result == DialogResult.Cancel) Application.Exit();
     }
 }
Esempio n. 36
0
        private bool UninstallSystemServic(string service,string servicePath,string commandLineOptions)
        {
            if (!System.IO.File.Exists(servicePath))
                return false;
            if (SystemServiceExists(service))
                return false;
            try
            {
                System.Configuration.Install.TransactedInstaller tranInstaller = new System.Configuration.Install.TransactedInstaller();
                System.Configuration.Install.AssemblyInstaller assemInstaller = new System.Configuration.Install.AssemblyInstaller(servicePath, new string[] { commandLineOptions });
                tranInstaller.Installers.Add(assemInstaller);
                System.Configuration.Install.InstallContext installContext = new System.Configuration.Install.InstallContext("install.log", new string[] { commandLineOptions });
                tranInstaller.Context=installContext;
                tranInstaller.Uninstall(null);
                return true;
            }
            catch(Exception e)
            {
                ShowError(e.StackTrace.ToString());
                return false;
            }

        }