Esempio n. 1
0
        private static void GenerateConfigFile(string filePath)
        {
            if (filePath == null)
            {
                filePath = Path.Combine(Directory.GetCurrentDirectory(), "RobotConnectionData.xml");
            }

            List <MobileDebugInfoSettings> lst = new List <MobileDebugInfoSettings>
            {
                new MobileDebugInfoSettings("192.168.1.1", 443, "admin", "admin", "backup_{ip}_{MM-dd-yy_HH-mm-ss}.zip"),
                new MobileDebugInfoSettings("192.168.1.2", 443, "admin", "admin", "backup_{ip}_{MM-dd-yy_HH-mm-ss}.zip")
            };

            if (!filePath.EndsWith(".xml"))
            {
                filePath += ".xml";
            }

            if (MobileBackup.SerializeConfiguration(filePath, lst))
            {
                Console.WriteLine($"The generated config file is located at: {filePath}");
            }
            else
            {
                Console.WriteLine($"ERROR: Could not generate config file located at: {filePath}");
            }
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            bool found = false;

            if (args.Count() > 0 && args[0].Length > 1 && (args[0][0] == '-' || args[0][0] == '/'))
            {
                switch (args[0].Substring(1).ToLower())
                {
                default:
                    break;

                case "help":
                case "h":
                    PrintHelp();
                    found = true;
                    break;

                case "generate":
                {
                    if (!Elevate(args))
                    {
                        if (args.Length >= 2)
                        {
                            GenerateConfigFile(args[1]);
                        }
                        else
                        {
                            GenerateConfigFile(null);
                        }
                    }
                    found = true;
                    break;
                }

                case "install":
                case "i":
                    if (!Elevate(args))
                    {
                        SelfInstaller.InstallMe();
                    }
                    found = true;
                    break;

                case "uninstall":
                case "u":
                    if (!Elevate(args))
                    {
                        SelfInstaller.UninstallMe();
                    }
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                if (Environment.UserInteractive)
                {
                    if (!Elevate(args))
                    {
                        Console.WriteLine("Console Mode");
                        MobileBackup s = new MobileBackup();
                        if (args.Length > 0)
                        {
                            s.Init(args, false);
                        }
                        else
                        {
                            s.Init(false);
                        }
                    }
                }
                else
                {
                    ServiceBase[] ServicesToRun;
                    ServicesToRun = new ServiceBase[]
                    {
                        new MobileBackup()
                    };
                    ServiceBase.Run(ServicesToRun);
                }
            }
            if (Environment.UserInteractive)
            {
                Console.WriteLine("Press any key to exit..");
                Console.ReadKey();
            }
        }