예제 #1
0
        private static bool CheckInstallation()
        {
            if (IsServiceInstalled())
            {
                return(true);
            }
            else if (HasRequiredInstallationPermission())
            {
                Console.WriteLine();
                Console.WriteLine("*  The Revalee service cannot run interactively until it is installed.");
                Console.Write("*  Would you like to install it now? [y/n] >");
                ConsoleKeyInfo keypress = Console.ReadKey(false);

                if (keypress.Key == ConsoleKey.Y)
                {
                    var installer = new CommandLineInstaller();
                    installer.Install();

                    Console.WriteLine();
                    Console.WriteLine();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                Console.WriteLine();
                Console.WriteLine("*  The Revalee service must be installed before it can be run interactively.");
                Console.WriteLine("*  However, the current permission level is not high enough to install now.");
                Console.WriteLine("*  Please run this executable again with elevated privileges to install.");
                return(false);
            }
        }
예제 #2
0
파일: Revalee.cs 프로젝트: javafun/Revalee
        public static void Main()
        {
            string[] commandLineArgs = Environment.GetCommandLineArgs();

            if (commandLineArgs == null || commandLineArgs.Length == 1)
            {
                if (Environment.UserInteractive)
                {
                    RunAsInteractive();
                }
                else
                {
                    RunAsService();
                }
            }
            else if (commandLineArgs.Length == 2)
            {
                if (commandLineArgs[1] == "-?" || string.Equals(commandLineArgs[1], "-help", StringComparison.OrdinalIgnoreCase))
                {
                    InteractiveExecution.Help();
                }
                else if (string.Equals(commandLineArgs[1], "-install", StringComparison.OrdinalIgnoreCase))
                {
                    try
                    {
                        var installer = new CommandLineInstaller();
                        installer.Install();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine();
                        Console.WriteLine(ex.Message);
                        Environment.ExitCode = 1;
                    }
                }
                else if (string.Equals(commandLineArgs[1], "-uninstall", StringComparison.OrdinalIgnoreCase))
                {
                    try
                    {
                        var installer = new CommandLineInstaller();
                        installer.Uninstall();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine();
                        Console.WriteLine(ex.Message);
                        Environment.ExitCode = 1;
                    }
                }
                else if (string.Equals(commandLineArgs[1], "-interactive", StringComparison.OrdinalIgnoreCase))
                {
                    RunAsInteractive();
                }
                else if (string.Equals(commandLineArgs[1], "-export", StringComparison.OrdinalIgnoreCase))
                {
                    TaskExporter.DumpToConsole();
                }
                else
                {
                    InteractiveExecution.Help();
                    Console.WriteLine();
                    Console.WriteLine("Error: Invalid switch `{0}`.", commandLineArgs[1]);
                    Environment.ExitCode = 1;
                }
            }
            else
            {
                InteractiveExecution.Help();
                Console.WriteLine();
                Console.WriteLine("Error: Invalid command line arguments.");
                Environment.ExitCode = 1;
            }
        }
예제 #3
0
		private static bool CheckInstallation()
		{
			if (IsServiceInstalled())
			{
				return true;
			}
			else if (HasRequiredInstallationPermission())
			{
				Console.WriteLine();
				Console.WriteLine("*  The Revalee service cannot run interactively until it is installed.");
				Console.Write("*  Would you like to install it now? [y/n] >");
				ConsoleKeyInfo keypress = Console.ReadKey(false);

				if (keypress.Key == ConsoleKey.Y)
				{
					var installer = new CommandLineInstaller();
					installer.Install();

					Console.WriteLine();
					Console.WriteLine();
					return true;
				}
				else
				{
					return false;
				}
			}
			else
			{
				Console.WriteLine();
				Console.WriteLine("*  The Revalee service must be installed before it can be run interactively.");
				Console.WriteLine("*  However, the current permission level is not high enough to install now.");
				Console.WriteLine("*  Please run this executable again with elevated privileges to install.");
				return false;
			}
		}