Beispiel #1
0
        public async Task <bool> Uninstall()
        {
            try
            {
                if (!CheckIsAdministrator())
                {
                    return(false);
                }

                StopService();

                ProcessEx.StartHidden("cmd.exe", "/c sc delete Remotely_Service").WaitForExit();

                await StopProcesses();

                ProgressMessageChanged?.Invoke(this, "Deleting files.");
                ClearInstallDirectory();
                ProcessEx.StartHidden("cmd.exe", $"/c timeout 5 & rd /s /q \"{InstallPath}\"");

                ProcessEx.StartHidden("netsh", "advfirewall firewall delete rule name=\"Remotely Desktop Unattended\"").WaitForExit();

                GetRegistryBaseKey().DeleteSubKeyTree(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Remotely", false);

                return(true);
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
                return(false);
            }
        }
Beispiel #2
0
        private void InstallService()
        {
            Logger.Write("Installing service.");
            ProgressMessageChanged?.Invoke(this, "Installing Remotely service.");
            var serv = ServiceController.GetServices().FirstOrDefault(ser => ser.ServiceName == "Remotely_Service");

            if (serv == null)
            {
                var command          = new string[] { "/assemblypath=" + Path.Combine(InstallPath, "Remotely_Agent.exe") };
                var context          = new InstallContext("", command);
                var serviceInstaller = new ServiceInstaller()
                {
                    Context          = context,
                    DisplayName      = "Remotely Service",
                    Description      = "Background service that maintains a connection to the Remotely server.  The service is used for remote support and maintenance by this computer's administrators.",
                    ServiceName      = "Remotely_Service",
                    StartType        = ServiceStartMode.Automatic,
                    DelayedAutoStart = true,
                    Parent           = new ServiceProcessInstaller()
                };

                var state = new System.Collections.Specialized.ListDictionary();
                serviceInstaller.Install(state);
                Logger.Write("Service installed.");
                serv = ServiceController.GetServices().FirstOrDefault(ser => ser.ServiceName == "Remotely_Service");

                ProcessEx.StartHidden("cmd.exe", "/c sc.exe failure \"Remotely_Service\" reset= 5 actions= restart/5000");
            }
            if (serv.Status != ServiceControllerStatus.Running)
            {
                serv.Start();
            }
            Logger.Write("Service started.");
        }
Beispiel #3
0
        private void AddFirewallRule()
        {
            var desktopExePath = Path.Combine(InstallPath, "Desktop", "Remotely_Desktop.exe");

            ProcessEx.StartHidden("netsh", "advfirewall firewall delete rule name=\"Remotely Desktop Unattended\"").WaitForExit();
            ProcessEx.StartHidden("netsh", $"advfirewall firewall add rule name=\"Remotely Desktop Unattended\" program=\"{desktopExePath}\" protocol=any dir=in enable=yes action=allow description=\"The agent that allows screen sharing and remote control for Remotely.\"").WaitForExit();
        }
Beispiel #4
0
        private void AddFirewallRule()
        {
            var screenCastPath = Path.Combine(InstallPath, "ScreenCast", "Remotely_ScreenCast.exe");

            ProcessEx.StartHidden("netsh", "advfirewall firewall delete rule name=\"Remotely ScreenCast\"").WaitForExit();
            ProcessEx.StartHidden("netsh", $"advfirewall firewall add rule name=\"Remotely ScreenCast\" program=\"{screenCastPath}\" protocol=any dir=in enable=yes action=allow profile=Private,Domain description=\"The agent that allows screen sharing and remote control for Remotely.\"").WaitForExit();
        }
Beispiel #5
0
        private async Task InstallDesktpRuntimeIfNeeded()
        {
            Logger.Write("Checking for .NET Core runtime.");
            var uninstallKeys    = new List <RegistryKey>();
            var runtimeInstalled = false;

            foreach (var subkeyName in GetRegistryBaseKey().OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\", false).GetSubKeyNames())
            {
                var subkey = GetRegistryBaseKey().OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + subkeyName, false);
                if (subkey?.GetValue("DisplayName")?.ToString()?.Contains($"Microsoft Windows Desktop Runtime - {CoreRuntimeVersion}") == true)
                {
                    runtimeInstalled = true;
                    break;
                }
            }

            if (!runtimeInstalled)
            {
                Logger.Write("Downloading .NET Core runtime.");
                ProgressMessageChanged.Invoke(this, "Downloading the .NET Core runtime.");
                var client = new WebClient();
                client.DownloadProgressChanged += (sender, args) =>
                {
                    ProgressValueChanged?.Invoke(this, args.ProgressPercentage);
                };
                var downloadUrl = string.Empty;
                if (Environment.Is64BitOperatingSystem)
                {
                    downloadUrl = "https://download.visualstudio.microsoft.com/download/pr/3240250e-6fe0-4258-af69-85abef6c00de/e01ee0af6c65d894f4a02bdf6705ec7b/windowsdesktop-runtime-3.1.2-win-x64.exe";
                }
                else
                {
                    downloadUrl = "https://download.visualstudio.microsoft.com/download/pr/b824906f-bd6e-4067-86a6-95c61620674d/cfcdab84a01cee94fdaa31271c3d4d47/windowsdesktop-runtime-3.1.2-win-x86.exe";
                }
                var targetFile = Path.Combine(Path.GetTempPath(), "windowsdesktop-runtime.exe");
                await client.DownloadFileTaskAsync(downloadUrl, targetFile);

                Logger.Write("Installing .NET Core runtime.");
                ProgressMessageChanged?.Invoke(this, "Installing the .NET Core runtime.");
                ProgressValueChanged?.Invoke(this, 0);

                await Task.Run(() => { ProcessEx.StartHidden(targetFile, "/install /quiet /norestart").WaitForExit(); });
            }
            else
            {
                Logger.Write(".NET Core runtime already installed.");
            }
        }
Beispiel #6
0
        private async Task InstallDesktpRuntimeIfNeeded()
        {
            Logger.Write("Checking for .NET Core runtime.");
            var uninstallKeys    = new List <RegistryKey>();
            var runtimeInstalled = false;

            foreach (var subkeyName in GetRegistryBaseKey().OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\", false).GetSubKeyNames())
            {
                var subkey = GetRegistryBaseKey().OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + subkeyName, false);
                if (subkey?.GetValue("DisplayName")?.ToString()?.Contains($"Microsoft Windows Desktop Runtime - {CoreRuntimeVersion}") == true)
                {
                    runtimeInstalled = true;
                    break;
                }
            }

            if (!runtimeInstalled)
            {
                Logger.Write("Downloading .NET Core runtime.");
                ProgressMessageChanged.Invoke(this, "Downloading the .NET Core runtime.");
                var client = new WebClient();
                client.DownloadProgressChanged += (sender, args) =>
                {
                    ProgressValueChanged?.Invoke(this, args.ProgressPercentage);
                };
                var downloadUrl = string.Empty;
                if (Environment.Is64BitOperatingSystem)
                {
                    downloadUrl = "https://download.visualstudio.microsoft.com/download/pr/5954c748-86a1-4823-9e7d-d35f6039317a/169e82cbf6fdeb678c5558c5d0a83834/windowsdesktop-runtime-3.1.3-win-x64.exe";
                }
                else
                {
                    downloadUrl = "https://download.visualstudio.microsoft.com/download/pr/7cd5c874-5d11-4e72-81f0-4a005d956708/0eb310169770c893407169fc3abaac4f/windowsdesktop-runtime-3.1.3-win-x86.exe";
                }
                var targetFile = Path.Combine(Path.GetTempPath(), "windowsdesktop-runtime.exe");
                await client.DownloadFileTaskAsync(downloadUrl, targetFile);

                Logger.Write("Installing .NET Core runtime.");
                ProgressMessageChanged?.Invoke(this, "Installing the .NET Core runtime.");
                ProgressValueChanged?.Invoke(this, 0);

                await Task.Run(() => { ProcessEx.StartHidden(targetFile, "/install /quiet /norestart").WaitForExit(); });
            }
            else
            {
                Logger.Write(".NET Core runtime already installed.");
            }
        }