diff --git a/TaskSchedulerConfig/App.config b/TaskSchedulerConfig/App.config
deleted file mode 100644
index 2c307fa..0000000
--- a/TaskSchedulerConfig/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/TaskSchedulerConfig/CommandLink.cs b/TaskSchedulerConfig/CommandLink.cs
deleted file mode 100644
index c42e807..0000000
--- a/TaskSchedulerConfig/CommandLink.cs
+++ /dev/null
@@ -1,298 +0,0 @@
-using System;
-using System.ComponentModel;
-using System.Drawing;
-using System.Runtime.InteropServices;
-using System.Windows.Forms;
-
-namespace TaskSchedulerConfig
-{
- internal class CommandLink : Button
- {
- private const int BCM_SETNOTE = 0x00001609;
- private const int BCM_SETSHIELD = 0x0000160C;
- private const int BS_COMMANDLINK = 0x0000000E;
-
- private Color activeTextColor;
- private string description;
- private Label lblDescription;
- private Label lblText;
- private bool mActivated;
- private DisplayStyle mDisplayStyle = DisplayStyle.Arrow;
- private bool mMouseOver;
- private PictureBox picIcon;
- private string text;
- private Color textColor;
-
- public CommandLink()
- {
- if (IsVistaOrLater)
- {
- FlatStyle = FlatStyle.System;
- }
- else
- {
- BackColor = Parent?.BackColor ?? Color.White;
- FlatStyle = FlatStyle.Standard;
- Size = new Size(400, 72);
- TabStop = false;
- UseVisualStyleBackColor = false;
-
- textColor = Color.FromArgb(21, 28, 85);
- activeTextColor = Color.FromArgb(7, 74, 229);
-
- lblText = new Label { AutoSize = true, BackColor = Color.Transparent, ForeColor = textColor, Location = new Point(27, 10), Name = "lblText", Size = new Size(0, 21), TabIndex = 0 };
- lblText.Font = new Font("Segoe UI", 12f, System.Drawing.FontStyle.Regular, GraphicsUnit.Point, (byte)0);
- lblText.ForeColor = Color.FromArgb((int)(byte)21, (int)(byte)28, (int)(byte)85);
- lblText.Click += (o, e) => OnClick(e);
- lblText.MouseLeave += CommandLink_MouseLeave;
- Controls.Add(lblText);
-
- lblDescription = new Label { BackColor = Color.Transparent, ForeColor = textColor, Location = new Point(33, 36), Name = "lblDescription", Size = new Size(364, 32), TabIndex = 1, UseCompatibleTextRendering = true };
- lblDescription.Font = new Font("Segoe UI", 9f, System.Drawing.FontStyle.Regular, GraphicsUnit.Point, (byte)0);
- lblDescription.ForeColor = Color.FromArgb((int)(byte)21, (int)(byte)28, (int)(byte)85);
- lblDescription.Click += (o, e) => OnClick(e);
- lblDescription.MouseLeave += CommandLink_MouseLeave;
- Controls.Add(lblDescription);
-
- picIcon = new PictureBox { BackColor = Color.Transparent, Location = new Point(10, 13), Name = "picIcon", Size = new Size(16, 16), TabIndex = 2, TabStop = false };
- picIcon.Image = Properties.Resources.restarrow;
- picIcon.Click += (o, e) => OnClick(e);
- picIcon.MouseLeave += CommandLink_MouseLeave;
- Controls.Add(picIcon);
-
- Click += (o, e) => Selected?.Invoke(this, EventArgs.Empty);
- MouseEnter += (o, e) => MouseOver = true;
- MouseLeave += CommandLink_MouseLeave;
-
- MouseOver = false;
- Activated = false;
- }
- }
-
- public CommandLink(DisplayStyle style, string text = null, string description = null) : this()
- {
- Style = style;
- Text = text;
- Description = description;
- }
-
- public event EventHandler Selected;
-
- public enum DisplayStyle
- {
- Arrow,
- Shield,
- }
-
- [Bindable(true)]
- [DefaultValue(null)]
- public string Description
- {
- get { return description; }
- set
- {
- if (IsVistaOrLater)
- SendMessage(Handle, BCM_SETNOTE, IntPtr.Zero, value);
- else
- lblDescription.Text = value;
- description = value;
- }
- }
-
- [Bindable(true)]
- [DefaultValue(DisplayStyle.Arrow)]
- public DisplayStyle Style
- {
- get { return mDisplayStyle; }
- set
- {
- bool bInv = false;
- if (mDisplayStyle != value)
- {
- bInv = true;
- }
- mDisplayStyle = value;
- if (bInv)
- {
- if (IsVistaOrLater)
- {
- if (mDisplayStyle == DisplayStyle.Shield)
- SendMessage(Handle, BCM_SETSHIELD, 0, 1);
- }
- else
- {
- base.FlatStyle = FlatStyle.Standard;
-
- switch (mDisplayStyle)
- {
- case DisplayStyle.Arrow:
- picIcon.Image = mMouseOver ? Properties.Resources.selarrow : Properties.Resources.restarrow;
- break;
-
- case DisplayStyle.Shield:
- picIcon.Image = Properties.Resources.shield;
- break;
-
- default:
- picIcon.Image = null;
- break;
- }
- Invalidate();
- }
- }
- }
- }
-
- [Bindable(true)]
- [DefaultValue(null)]
- public override string Text
- {
- get { return text; }
- set
- {
- if (IsVistaOrLater)
- base.Text = value;
- else
- lblText.Text = value;
- text = value;
- }
- }
-
- protected override CreateParams CreateParams
- {
- get
- {
- CreateParams cp = base.CreateParams;
- if (IsVistaOrLater)
- cp.Style |= BS_COMMANDLINK;
- return cp;
- }
- }
-
- private bool Activated
- {
- get { return mActivated; }
- set
- {
- bool bInv = false;
- if (mActivated != value)
- bInv = true;
- mActivated = value;
- if (bInv)
- Invalidate();
- }
- }
-
- private bool Default => (object.ReferenceEquals(FindForm().AcceptButton, this));
-
- private static bool IsVistaOrLater => System.Environment.OSVersion.Version.Major > 5;
-
- private bool MouseOver
- {
- get { return mMouseOver; }
- set
- {
- bool bInv = false;
- if (mMouseOver != value)
- bInv = true;
- mMouseOver = value;
- if (!IsVistaOrLater && bInv)
- {
- if (mMouseOver == true)
- {
- lblText.ForeColor = activeTextColor;
- lblDescription.ForeColor = activeTextColor;
- if (Style == DisplayStyle.Arrow)
- picIcon.Image = Properties.Resources.selarrow;
- }
- else
- {
- lblText.ForeColor = textColor;
- lblDescription.ForeColor = textColor;
- if (Style == DisplayStyle.Arrow)
- {
- picIcon.Image = Properties.Resources.restarrow;
- }
- }
- Invalidate();
- }
- }
- }
-
- public void ActivateChanged(bool activate)
- {
- Activated = activate;
- }
-
- protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
- {
- if (IsVistaOrLater)
- {
- base.OnPaint(e);
- }
- else
- {
- if (base.FlatStyle != FlatStyle.Standard)
- base.FlatStyle = FlatStyle.Standard;
-
- Pen oPen = null;
- Rectangle r = ClientRectangle;
- Brush oBrush = null;
-
- r.Width -= 1;
- r.Height -= 1;
-
- if (MouseOver)
- {
- //the mouse is over is, draw the hover border
- oPen = new Pen(Color.FromArgb(198, 198, 198));
- oBrush = new System.Drawing.Drawing2D.LinearGradientBrush(ClientRectangle, BackColor, Color.FromArgb(246, 246, 246), System.Drawing.Drawing2D.LinearGradientMode.Vertical);
- }
- else if (Activated && Default)
- {
- //draw the blue border
- oPen = new Pen(Color.FromArgb(198, 244, 255));
- r.Width -= 2;
- r.Height -= 2;
- r.X += 1;
- r.Y += 1;
- }
-
- if (oBrush == null)
- {
- e.Graphics.FillRectangle(new SolidBrush(BackColor), ClientRectangle);
- }
- else
- {
- e.Graphics.FillRectangle(oBrush, ClientRectangle);
- oBrush.Dispose();
- }
- if (oPen != null)
- {
- oPen.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;
- e.Graphics.DrawLine(oPen, r.X + 2, r.Y, r.X + r.Width - 2, r.Y);
- e.Graphics.DrawLine(oPen, r.X + r.Width - 2, r.Y, r.X + r.Width, r.Y + 2);
- e.Graphics.DrawLine(oPen, r.X + r.Width, r.Y + 2, r.X + r.Width, r.Y + r.Height - 2);
- e.Graphics.DrawLine(oPen, r.X + r.Width, r.Y + r.Height - 2, r.X + r.Width - 2, r.Y + r.Height);
- e.Graphics.DrawLine(oPen, r.X + r.Width - 2, r.Y + r.Height, r.X + 2, r.Y + r.Height);
- e.Graphics.DrawLine(oPen, r.X + 2, r.Y + r.Height, r.X, r.Y + r.Height - 2);
- e.Graphics.DrawLine(oPen, r.X, r.Y + r.Height - 2, r.X, r.Y + 2);
- e.Graphics.DrawLine(oPen, r.X, r.Y + 2, r.X + 2, r.Y);
- oPen.Dispose();
- }
- }
- }
-
- [DllImport("user32.dll", CharSet = CharSet.Unicode)]
- private static extern int SendMessage(IntPtr hWnd, UInt32 Msg, int wParam, int lParam);
-
- [DllImport("user32", CharSet = CharSet.Unicode)]
- private static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, string lParam);
-
- private void CommandLink_MouseLeave(object sender, System.EventArgs e)
- {
- MouseOver = ClientRectangle.Contains(PointToClient(Control.MousePosition));
- Invalidate();
- }
- }
-}
\ No newline at end of file
diff --git a/TaskSchedulerConfig/Configurer.cs b/TaskSchedulerConfig/Configurer.cs
deleted file mode 100644
index 3b1f2e9..0000000
--- a/TaskSchedulerConfig/Configurer.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-using System.Runtime.InteropServices;
-using System.Security.Principal;
-using System.ServiceProcess;
-using System.Text;
-
-namespace TaskSchedulerConfig
-{
- class Configurer
- {
- Validator v;
-
- public Configurer(Validator validator)
- {
- v = validator;
- }
-
- internal bool EnableFirewall(object obj)
- {
- v.Firewall.Enabled = true;
- return v.Firewall.Enabled;
- }
-
- internal bool EnableFirewallRule(object obj)
- {
- if (obj is Firewall.Rule)
- {
- v.Firewall.Rules[(Firewall.Rule)obj] = true;
- return v.Firewall.Rules[(Firewall.Rule)obj];
- }
- throw new ArgumentException();
- }
-
- internal bool RunRemoteRegistryService(object obj)
- {
- v.RemoteRegistryService.SetStartType(ServiceStartMode.Automatic);
- v.RemoteRegistryService.Start();
- return v.RemoteRegistryServiceRunning;
- }
- }
-
- internal static class ServiceHelper
- {
- [DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
- [return: MarshalAs(UnmanagedType.Bool)]
- private static extern Boolean ChangeServiceConfig(IntPtr hService, UInt32 nServiceType, UInt32 nStartType, UInt32 nErrorControl, String lpBinaryPathName, String lpLoadOrderGroup, IntPtr lpdwTagId, [In] char[] lpDependencies, String lpServiceStartName, String lpPassword, String lpDisplayName);
-
- private const uint SERVICE_NO_CHANGE = 0xFFFFFFFF;
-
- public static void SetStartType(this ServiceController svc, ServiceStartMode mode)
- {
- using (var serviceHandle = svc.ServiceHandle)
- if (!ChangeServiceConfig(serviceHandle.DangerousGetHandle(), SERVICE_NO_CHANGE, (uint)mode, SERVICE_NO_CHANGE, null, null, IntPtr.Zero, null, null, null, null))
- throw new ExternalException("Could not change service start type.", new Win32Exception());
- }
- }
-}
diff --git a/TaskSchedulerConfig/Diagnostic.cs b/TaskSchedulerConfig/Diagnostic.cs
deleted file mode 100644
index 0ac61fe..0000000
--- a/TaskSchedulerConfig/Diagnostic.cs
+++ /dev/null
@@ -1,260 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Security.AccessControl;
-using System.Security.Policy;
-using System.Security.Principal;
-using System.ServiceProcess;
-
-namespace TaskSchedulerConfig
-{
- class Diagnostics : List
- {
- ServicesDetail v;
-
- public Diagnostics(string server)
- {
- v = new ServicesDetail(server);
-
- Add(new Diagnostic
- {
- Name = "V1 Local Access: User has insufficient permissions to schedule tasks",
- Description = "To schedule a V1 task, the current user must be a member of the Administrators, Backup Operators, or Server Operators group on the local computer.",
- Condition = o => v.IsLocal,
- Troubleshooter = o => !(v.UserIsAdmin || v.UserIsBackupOperator || v.UserIsServerOperator),
- Resolution = new Resolution
- {
- Name = "Add user to Administrators group",
- Description = "Adding the user to the Administrators group will give it the right to schedule a V1 task.",
- RequiresConsent = true,
- RequiresElevation = true,
- Resolver = AddUserRole
- }
- });
-
- Add(new Diagnostic
- {
- Name = "V1 Remote Access: Firewall is not enabled",
- Description = "Firewall must be enabled on local system.",
- Condition = o => v.IsLocal,
- Troubleshooter = o => !v.Firewall.Enabled,
- Resolution = new Resolution
- {
- Name = "Enable the firewall",
- Description = "Enabling the firewall allows for the Task Scheduler to secure its interactions.",
- RequiresElevation = true,
- Resolver = o => v.Firewall.Enabled = true
- }
- });
-
- Add(new Diagnostic
- {
- Name = "V1 Remote Access: \"File and Printer Sharing\" rule on the firewall is not enabled",
- Description = "The \"File and Printer Sharing\" rule must be enabled in order for the Task Scheduler V1 to share its information with other computers.",
- Troubleshooter = o => !v.Firewall.Rules[Firewall.Rule.FileAndPrinterSharing],
- Resolution = new Resolution
- {
- Name = "Enable the \"File and Printer Sharing\" rule on the firewall",
- Description = "Enabling the \"File and Printer Sharing\" rule on the firewall allows the Task Scheduler V1 to share its information with other computers.",
- RequiresElevation = true,
- Resolver = o => v.Firewall.Rules[Firewall.Rule.FileAndPrinterSharing] = true
- }
- });
-
- Add(new Diagnostic
- {
- Name = "V1 Local Access: Invalid permissions on the \"%windir%\\Tasks\" directory",
- Description = "Permissions on the \"%windir%\\Tasks\" directory do not allow V1 tasks to be created or edited by the current user",
- Condition = o => v.IsLocal,
- Troubleshooter = CheckTasksDirPerms,
- Resolution = new Resolution
- {
- Name = "Give current user access to \"%windir%\\Tasks\" directory",
- Description = "Giving the current user access to the \"%windir%\\Tasks\" directory will, in effect, give the user the right to create or edit V1 tasks.",
- RequiresConsent = true,
- RequiresElevation = true,
- Resolver = UpdateTasksDirPerms
- }
- });
-
- if (System.Environment.OSVersion.Version.Major < 6)
- return;
-
- Add(new Diagnostic
- {
- Name = "V2 Local Access: User has insufficient permissions to schedule tasks",
- Description = "To schedule a V2 task, the current user must have \"Log on as a batch job\" and \"Log on as a service\" privileges.",
- Condition = o => v.IsLocal,
- //Troubleshooter = o => !v.UserRights[LocalSecurityAccountPrivileges.LogonAsBatchJob],
- RequiresElevation = true,
- Troubleshooter = o => !v.UserAccessRights[LocalSecurity.LsaSecurityAccessRights.BatchLogon],
- Resolution = new Resolution
- {
- Name = "Grant user \"Log on as a batch job\" right",
- Description = "Adding the \"Log on as a batch job\" right to the user will give it the right to schedule a V2 task on this and other computers.",
- RequiresConsent = true,
- RequiresElevation = true,
- Resolver = o => v.UserAccessRights[LocalSecurity.LsaSecurityAccessRights.BatchLogon] = true,
- }
- });
-
- Add(new Diagnostic
- {
- Name = "V2 Remote Access: \"Remote Task Management\" rule on the firewall is not enabled",
- Description = "The \"Remote Task Management\" rule must be enabled in order for the Task Scheduler V2 to share its information with other computers.",
- Troubleshooter = o => !v.Firewall.Rules[Firewall.Rule.RemoteTaskManagement],
- Resolution = new Resolution
- {
- Name = "Enable the \"Remote Task Management\" rule on the firewall",
- Description = "Enabling the \"Remote Task Management\" rule on the firewall allows the Task Scheduler V2 to share its information with other computers.",
- RequiresElevation = true,
- Resolver = o => v.Firewall.Rules[Firewall.Rule.RemoteTaskManagement] = true
- }
- });
-
- Add(new Diagnostic
- {
- Name = "V2 Remote Event Access: \"Remote Event Log Management\" rule on the firewall is not enabled",
- Description = "The \"Remote Event Log Management\" rule must be enabled in order for the Task Scheduler V2 to share its events with other computers.",
- Troubleshooter = o => !v.Firewall.Rules[Firewall.Rule.RemoteEventLogManagment],
- Resolution = new Resolution
- {
- Name = "Enable the \"Remote Event Log Management\" rule on the firewall",
- Description = "Enabling the \"Remote Event Log Management\" rule on the firewall allows the Task Scheduler V2 to share its events with other computers.",
- RequiresElevation = true,
- Resolver = o => v.Firewall.Rules[Firewall.Rule.RemoteEventLogManagment] = true
- }
- });
-
- Add(new Diagnostic
- {
- Name = "V2 Remote Access: \"Remote Registry\" service is not running",
- Description = "The \"Remote Registry\" service must be running in order for the Task Scheduler V1 to connect to this computer.",
- Troubleshooter = o => !v.RemoteRegistryServiceRunning,
- Resolution = new Resolution
- {
- Name = "Automatically start the \"Remote Registry\" service",
- Description = "Starting the \"Remote Registry\" service and setting that service to start automatically will ensure that other V1 computers can connect to this computer.",
- RequiresElevation = true,
- Resolver = StartRemoteRegistryService
- }
- });
- }
-
- public event EventHandler ShowMessage;
-
- public IEnumerable Issues
- {
- get
- {
- foreach (var item in this)
- {
- if (item.HasIssue.HasValue && item.HasIssue.Value)
- yield return item;
- }
- }
- }
-
- public IEnumerable NonIsseus
- {
- get
- {
- foreach (var item in this)
- {
- if (item.Condition(null) && item.HasIssue.HasValue && !item.HasIssue.Value)
- yield return item;
- }
- }
- }
-
- public string Server => v.Server;
-
- public IEnumerable UnRun
- {
- get
- {
- foreach (var item in this)
- {
- if (item.Condition(null) && !item.HasIssue.HasValue)
- yield return item;
- }
- }
- }
-
- private void ShowThisMessage(string s) { ShowMessage?.Invoke(this, new ShowMessageEventArgs(s)); }
-
- private void AddUserRole(object role)
- {
- throw new InvalidOperationException("You must add the current user manually to the Administrators, Backup Operators, or Server Operators group.");
- }
-
- private bool CheckTasksDirPerms(object obj)
- {
- ShowThisMessage("Checking permissions on \\Windows\\Tasks folder...");
- var dir = new DirectoryInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "Tasks"));
- return !DirectoryHasPermission(dir, FileSystemRights.FullControl);
- }
-
- private static bool DirectoryHasPermission(DirectoryInfo DirectoryPath, FileSystemRights AccessRight)
- {
- if (DirectoryPath != null)
- try { return (DirectoryPath.GetEffectiveRights(WindowsIdentity.GetCurrent()) & AccessRight) == AccessRight; } catch { }
- return false;
- }
-
- private void StartRemoteRegistryService(object obj)
- {
- if (v.RemoteRegistryService.Status != System.ServiceProcess.ServiceControllerStatus.Stopped && v.RemoteRegistryService.CanStop)
- {
- ShowThisMessage("Stopping \"Remote Registry\" service...");
- v.RemoteRegistryService.Stop();
- v.RemoteRegistryService.WaitForStatus(System.ServiceProcess.ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(30));
- }
- if (v.RemoteRegistryService.Status == System.ServiceProcess.ServiceControllerStatus.Stopped)
- {
- ShowThisMessage("Setting \"Remote Registry\" service to start automatically...");
- v.RemoteRegistryService.SetStartType(System.ServiceProcess.ServiceStartMode.Automatic);
- ShowThisMessage("Starting \"Remote Registry\" service...");
- v.RemoteRegistryService.Start();
- v.RemoteRegistryService.WaitForStatus(System.ServiceProcess.ServiceControllerStatus.Running, TimeSpan.FromSeconds(30));
- }
- }
-
- private void UpdateTasksDirPerms(object obj)
- {
- ShowThisMessage("Adding user rights to \\Windows\\Tasks folder...");
- string dir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "Tasks");
- var di = new DirectoryInfo(dir);
- var sec = di.GetAccessControl(AccessControlSections.Access);
- sec.AddAccessRule(new FileSystemAccessRule(v.sid, FileSystemRights.Modify, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow));
- di.SetAccessControl(sec);
- }
-
- public class Diagnostic
- {
- public bool? HasIssue { get; set; }
- public bool? Resolved { get; set; }
- public string Name { get; set; }
- public string Description { get; set; }
- public Predicate