public void UnconfigureService() { if (!_windowsServiceHelper.IsRunningInElevatedMode()) { Trace.Error("Needs Administrator privileges for unconfigure windows service agent."); throw new SecurityException(StringUtil.Loc("NeedAdminForUnconfigWinServiceAgent")); } string serviceConfigPath = HostContext.GetConfigFile(WellKnownConfigFile.Service); string serviceName = File.ReadAllText(serviceConfigPath); if (_windowsServiceHelper.IsServiceExists(serviceName)) { _windowsServiceHelper.StopService(serviceName); _windowsServiceHelper.UninstallService(serviceName); // Delete local group we created during configure. string agentRoot = HostContext.GetDirectory(WellKnownDirectory.Root); string workFolder = HostContext.GetDirectory(WellKnownDirectory.Work); _windowsServiceHelper.RevokeDirectoryPermissionForAccount(new[] { agentRoot, workFolder }); // Remove registry key only on Windows _windowsServiceHelper.DeleteVstsAgentRegistryKey(); } IOUtil.DeleteFile(serviceConfigPath); }
public void UnconfigureService() { string serviceConfigPath = IOUtil.GetServiceConfigFilePath(); string serviceName = File.ReadAllText(serviceConfigPath); if (_windowsServiceHelper.IsServiceExists(serviceName)) { _windowsServiceHelper.StopService(serviceName); _windowsServiceHelper.UninstallService(serviceName); // Delete local group we created during confiure. RevokeDirectoryPermissionForAccount(); // Remove registry key only on Windows _windowsServiceHelper.DeleteVstsAgentRegistryKey(); } IOUtil.DeleteFile(serviceConfigPath); }
public void UnconfigureService() { if (!_windowsServiceHelper.IsRunningInElevatedMode()) { Trace.Error("Needs Administrator privileges for unconfigure windows service runner."); throw new SecurityException("Needs Administrator privileges for unconfiguring runner that running as windows service."); } string serviceConfigPath = HostContext.GetConfigFile(WellKnownConfigFile.Service); string serviceName = File.ReadAllText(serviceConfigPath); if (_windowsServiceHelper.IsServiceExists(serviceName)) { _windowsServiceHelper.StopService(serviceName); _windowsServiceHelper.UninstallService(serviceName); // Delete local group we created during configure. string runnerRoot = HostContext.GetDirectory(WellKnownDirectory.Root); string workFolder = HostContext.GetDirectory(WellKnownDirectory.Work); _windowsServiceHelper.RevokeDirectoryPermissionForAccount(new[] { runnerRoot, workFolder }); } IOUtil.DeleteFile(serviceConfigPath); }