Ejemplo n.º 1
0
        public void RestartShoppingCartService()
        {
            //--need to impersonate with the user having appropriate rights to start the service
            Impersonate objImpersonate = new Impersonate(_domainName, _userName, _userPassword);

            if (objImpersonate.impersonateValidUser())
            {
                var starter = new WindowsServiceStarter(_nameOfService);
                starter.StopWindowService();
                System.Threading.Thread.Sleep(1000);
                starter.StartWindowService();
                objImpersonate.undoImpersonation();
            }
        }