Exemplo n.º 1
0
        private static bool RequireAdministratorPrivilages()
        {
            var isAdmin = IsUserAdministrator();

            if (!isAdmin)
            {
                var oldColor = ConsoleWrapper.ForegroundColor;
                ConsoleWrapper.ForegroundColor = ConsoleColor.Red;
                ConsoleWrapper.WriteLine("You must be system administrator");
                ConsoleWrapper.ForegroundColor = oldColor;
                Log.Error("You must be system administrator");
            }

            return(isAdmin);
        }
Exemplo n.º 2
0
        private static void Install(bool prompt = true)
        {
            ConsoleWrapper.Alloc();

            if (!RequireAdministratorPrivilages())
            {
                return;
            }

            //if (prompt)
            //{
            //    ConsoleWrapper.Write("Do you want to install RDP Protocol handler? (for details use /?) [Y]es [N]o:");
            //    var result = ConsoleWrapper.ReadLine();
            //    if (result?.ToLower() != "y") return;
            //}

            Uninstall();

            //-- get assembly info
            var assembly        = Assembly.GetExecutingAssembly();
            var handlerLocation = assembly.Location;

            //-- create registy structure
            var rootKey        = Registry.ClassesRoot.CreateSubKey(REGISTRY_KEY_NAME);
            var defaultIconKey = rootKey?.CreateSubKey("DefaultIcon");
            var commandKey     = rootKey?.CreateSubKey("shell")?.CreateSubKey("open")?.CreateSubKey("command");

            rootKey?.SetValue("", "rdp:Remote Desktop Protocol");
            rootKey?.SetValue("URL Protocol", "");
            defaultIconKey?.SetValue("", @"C:\Windows\System32\mstsc.exe");
            commandKey?.SetValue("", $@"""{handlerLocation}"" ""%1""");

            //--
            Log.Info("RDP Protocol Handler installed");
            ConsoleWrapper.WriteLine("RDP Protocol Handler installed");
            ConsoleWrapper.WriteLine($"WARNING: Do not move this '{assembly.FullName}' to other location, otherwise handler will not work. If you change the location run installation process again.");
        }
Exemplo n.º 3
0
 private static void Help()
 {
     ConsoleWrapper.Alloc();
     ConsoleWrapper.WriteLine("For help go to: https://github.com/konradsikorski/RdpProtocolHandler");
 }