private void RevokeDirectoryPermissionForAccount() { Trace.Entering(); string groupName = _windowsServiceHelper.GetUniqueBuildGroupName(); Trace.Info(StringUtil.Format("Calculated unique group name {0}", groupName)); // remove the group from the work folder string workFolder = IOUtil.GetWorkPath(HostContext); if (Directory.Exists(workFolder)) { Trace.Info(StringUtil.Format($"Remove the group {groupName} for the folder {workFolder}.")); _windowsServiceHelper.RemoveGroupFromFolderSecuritySetting(workFolder, groupName); } //remove group from agent root folder string agentRoot = IOUtil.GetRootPath(); if (Directory.Exists(agentRoot)) { Trace.Info(StringUtil.Format($"Remove the group {groupName} for the folder {agentRoot}.")); _windowsServiceHelper.RemoveGroupFromFolderSecuritySetting(agentRoot, groupName); } //delete group Trace.Info(StringUtil.Format($"Delete the group {groupName}.")); _windowsServiceHelper.DeleteLocalGroup(groupName); }