//private string _serviceUserName; //private string _servicePassword; internal void UpdateInstanceOnServer(Business.Server server, SetStatusLabelDelegate setStatusLabelDelegate) { //ImpersonateUser impersonateUser = null; try { //if (server.UseImpersonation == true) //{ // setStatusLabelDelegate("Impersonating user: "******"Checking MemCacheD.exe on remote server."); string binaryPath = server.EnsureExecutableIsAvailabeOnServer(false); string userName = null; string password = null; if (server.UseImpersonation == true) { userName = server.UserName; password = Encryption.Decrypt(server.Password); } setStatusLabelDelegate("Updating service on remote server."); WmiService.CreateOrUpdate(server.ServerName, userName, password, this.ServiceName, this.DisplayName, this.CreateImagePath(), StartMode.Auto, null, null); } finally { //if (impersonateUser != null && impersonateUser.IsImpersonating == true) // impersonateUser.Undo(); } /* string description = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\" + _serviceController.ServiceName).GetValue("Description").ToString(); string imagePath = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\" + _serviceController.ServiceName).GetValue("ImagePath").ToString(); string newImagePath = imagePath.Substring(0, imagePath.LastIndexOf("memcached.exe") + ((string)("memcached.exe")).Length); int tcpPort; if (int.TryParse(txtTcpPort.Text, out tcpPort) == true) newImagePath += " -p " + tcpPort; int udpPort; if (int.TryParse(txtUdpPort.Text, out udpPort) == true) newImagePath += " -U " + udpPort; if (chkMaximizeCoreFile.Checked == true) newImagePath += " -r"; int maxMemory; if (int.TryParse(txtMemoryLimit.Text, out maxMemory) == true) newImagePath += " -m " + maxMemory; Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\" + _serviceController.ServiceName, true).SetValue("ImagePath", newImagePath); Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\" + _serviceController.ServiceName, true).SetValue("DisplayName", txtInstanceName.Text); bool requiresRestart = false; if (_serviceController.Status == ServiceControllerStatus.Running) { requiresRestart = true; lblStatus.Text = "Stopping " + txtInstanceName.Text; Refresh(); _serviceController.Stop(); } lblStatus.Text = "Removing " + _serviceController.DisplayName; Refresh(); ServiceUtility.UninstallService(_serviceController.ServiceName); lblStatus.Text = "Reinstalling " + txtInstanceName.Text; Refresh(); ServiceUtility.InstallService(_serviceController.ServiceName, txtInstanceName.Text, description, newImagePath); if (requiresRestart == true) { lblStatus.Text = "Starting " + txtInstanceName.Text; Refresh(); _serviceController.Start(); } lblStatus.Text = "Ready."; */ }