Exemple #1
0
        /// <summary>
        /// 安裝 uvnc_service 服務 <br/>
        /// 權限不夠時: <br/>
        /// 1. 從當前user temp文件夾下讀取文件 <br/>
        /// 2. 檢查 UVncOption.AdminUser 和 UVncOption.AdminPasswd <br/>
        /// 3. 驗證不通過 則 彈出 賬戶密碼 輸入框
        /// </summary>
        /// <param name="waitSecond">等待秒數</param>
        /// <returns></returns>
        public bool InstallVncServiceWait_Authorize(int waitSecond)
        {
            if (VncServiceExist())
            {
                return(true);
            }

            if (InvokeValidateAccountOrOpenInputAccountBox())
            {
                var cmd = new CMDHelper();
                if (cmd.CreateProcessExeAsUser(_winvncExe, "-install", UVncOption.AdminUser, UVncOption.AdminPasswd))
                {
                    for (int i = 0; i < waitSecond; i++)
                    {
                        Thread.Sleep(1000);
                        if (VncServiceExist())
                        {
                            using var service = new ServiceController(_vncServiceName);
                            if (service.Status == ServiceControllerStatus.Running || service.Status == ServiceControllerStatus.StartPending)
                            {
                                return(true);
                            }

                            string arg = "start " + _vncServiceName;
                            cmd.CreateProcessExeAsUser(_scExe, arg, UVncOption.AdminUser, UVncOption.AdminPasswd);
                            service.WaitForStatus(ServiceControllerStatus.Running, _waitServiceTime);
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Exemple #2
0
        //public void SetPasswordToUltraVNCini(string password)
        //{
        //    var cmd = new CMDHelper();
        //    cmd.CreateProcessExe(_setpasswordExe, password + " " + password);
        //}
        #endregion

        #region CreateWinVncProcess
        public void CreateWinVncProcessWait(int waitSecond)
        {
            if (!WinVncProcessExist())
            {
                var cmd = new CMDHelper();
                cmd.CreateProcessExe(_winvncExe, "-run");

                for (int i = 0; i < waitSecond; i++)
                {
                    Thread.Sleep(1000);
                    if (WinVncProcessExist())
                    {
                        return;
                    }
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// 刪除 uvnc_service 服務
        /// </summary>
        /// <param name="waitSecond">等待秒數</param>
        /// <returns></returns>
        public bool UninstallVncServiceWait_Authorize(int waitSecond)
        {
            if (VncServiceExist())
            {
                StopVncService_Authorize();
                var cmd = new CMDHelper();
                if (cmd.CreateProcessExe(_winvncExe, "-uninstallhelper"))
                {
                    for (int i = 0; i < waitSecond; i++)
                    {
                        Thread.Sleep(1000);
                        if (!VncServiceExist())
                        {
                            return(true);
                        }
                    }
                }
                return(false);
            }

            return(true);
        }
Exemple #4
0
        /// <summary>
        /// 刪除 uvnc_service 服務 <br/>
        /// 權限不夠時: <br/>
        /// 1. 從當前user temp文件夾下讀取文件 <br/>
        /// 2. 檢查 UVncOption.AdminUser 和 UVncOption.AdminPasswd <br/>
        /// 3. 驗證不通過 則 彈出 賬戶密碼 輸入框
        /// </summary>
        /// <param name="waitSecond">等待秒數</param>
        /// <returns></returns>
        public bool UninstallVncServiceWait_Authorize(int waitSecond)
        {
            if (!VncServiceExist())
            {
                return(true);
            }

            if (InvokeValidateAccountOrOpenInputAccountBox())
            {
                var cmd = new CMDHelper();
                if (cmd.CreateProcessExeAsUser(_winvncExe, "-uninstall", UVncOption.AdminUser, UVncOption.AdminPasswd))
                {
                    for (int i = 0; i < waitSecond; i++)
                    {
                        Thread.Sleep(1000);
                        if (!VncServiceExist())
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }