15 Commits
2.1 ... master

15 changed files with 913 additions and 241 deletions
Split View
  1. +1
    -1
      README.md
  2. +71
    -153
      src/Actions/.NET.cs
  3. +239
    -0
      src/Actions/Deameliorate.cs
  4. +11
    -0
      src/Actions/Users.cs
  5. +1
    -0
      src/Ameliorated.ConsoleUtils/ConsoleTUI/FrameWriteMethods.cs
  6. +4
    -4
      src/Ameliorated.ConsoleUtils/ConsoleTUI/Menu.cs
  7. +10
    -0
      src/App.config
  8. +1
    -1
      src/Globals.cs
  9. +220
    -0
      src/Misc/FolderPicker.cs
  10. +261
    -0
      src/Misc/SelectWindowsImage.cs
  11. +15
    -2
      src/NSudo.cs
  12. +6
    -33
      src/Program.cs
  13. +42
    -27
      src/amecs.csproj
  14. +7
    -0
      src/app.manifest
  15. +24
    -20
      src/packages.config

+ 1
- 1
README.md View File

@ -6,7 +6,7 @@ Script for automating a large assortment of AME related actions.
## Usage
You can download the script by going to the [latest release](https://git.ameliorated.info/Styris/amecs/releases/latest) and selecting `amecs.exe` from the **Downloads** section. Once downloaded, simply run `amecs.cmd`.
You can download the script by going to the [latest release](https://git.ameliorated.info/Styris/amecs/releases/latest) and selecting `amecs.exe` from the **Downloads** section. Once downloaded, simply run `amecs.exe`.
## Summary


+ 71
- 153
src/Actions/.NET.cs View File

@ -7,7 +7,7 @@ using System.Runtime.InteropServices;
using System.Security;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using amecs.Misc;
using Ameliorated.ConsoleUtils;
using Microsoft.Dism;
@ -15,181 +15,99 @@ namespace amecs.Actions
{
public class _NET
{
private static string _mountedPath;
private static string _isoPath;
private static void Unmount()
{
if (_isoPath == "none")
return;
SelectWindowsImage.DismountIso(_isoPath);
}
public static bool Install()
{
var key = new ChoicePrompt() { Text = "A Windows ISO must be provided to install .NET 3.5.\r\nPress any key to select an ISO: ", AnyKey = true }.Start();
(_mountedPath, _isoPath, _, _, _) = SelectWindowsImage.GetMediaPath(true);
if (_mountedPath == null) return false;
if (key == null)
if (!Directory.Exists(_mountedPath + @"\sources\sxs") || !Directory.GetFiles(_mountedPath + @"\sources\sxs", "*netfx3*").Any())
{
Unmount();
Console.WriteLine();
ConsoleTUI.OpenFrame.Close("ISO/USB/folder does not contain the required files.",
ConsoleColor.Red, Console.BackgroundColor, new ChoicePrompt() { AnyKey = true, Text = "Press any key to return to the Menu: " });
return false;
}
var dialog = new System.Windows.Forms.OpenFileDialog();
dialog.Filter = "ISO Files (*.ISO)| *.ISO"; // Filter files by extension
dialog.Multiselect = false;
dialog.InitialDirectory = Globals.UserFolder;
NativeWindow window = new NativeWindow();
window.AssignHandle(Process.GetCurrentProcess().MainWindowHandle);
if (dialog.ShowDialog(window) == DialogResult.OK)
ConsoleTUI.OpenFrame.WriteCentered("\r\nInstalling .NET 3.5");
var topCache = Console.CursorTop;
var leftCache = Console.CursorLeft;
Console.WriteLine();
var inProgress = false;
try
{
string file;
try
{
file = dialog.FileName;
} catch (SecurityException e)
{
Console.WriteLine();
ConsoleTUI.OpenFrame.Close("Security error: " + e.Message, ConsoleColor.Red, Console.BackgroundColor, new ChoicePrompt() { AnyKey = true, Text = "Press any key to return to the Menu: " });
return false;
}
Console.WriteLine();
ConsoleTUI.OpenFrame.WriteCentered("\r\nMounting ISO");
string letter;
using (new ConsoleUtils.LoadingIndicator(true))
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = "PowerShell.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = $"-NoP -C \"(Mount-DiskImage '{file}' -PassThru | Get-Volume).DriveLetter\"";
startInfo.RedirectStandardOutput = true;
var proc = Process.Start(startInfo);
proc.WaitForExit();
letter = proc.StandardOutput.ReadLine();
}
if (!Directory.Exists(letter + @":\sources\sxs") || !Directory.GetFiles(letter + @":\sources\sxs", "*netfx3*").Any())
{
try
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = "PowerShell.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = $"-NoP -C \"Dismount-DiskImage '{file}'\"";
startInfo.RedirectStandardOutput = true;
var proc = Process.Start(startInfo);
proc.WaitForExit();
} catch (Exception e)
{
}
Console.WriteLine();
ConsoleTUI.OpenFrame.Close("ISO does not contain the required files.", ConsoleColor.Red, Console.BackgroundColor, new ChoicePrompt() { AnyKey = true, Text = "Press any key to return to the Menu: " });
return false;
}
ConsoleTUI.OpenFrame.WriteCentered("\r\nInstalling .NET 3.5");
var topCache = Console.CursorTop;
var leftCache = Console.CursorLeft;
Console.WriteLine();
bool inProgress = false;
try
using var indicator = new ConsoleUtils.LoadingIndicator();
DismApi.Initialize(DismLogLevel.LogErrors);
using (var session = DismApi.OpenOnlineSession())
{
using (var indicator = new ConsoleUtils.LoadingIndicator())
var stdout = GetStdHandle(-11);
var indicatorStopped = false;
var maxHashTags = (ConsoleTUI.OpenFrame.DisplayWidth - 5);
DismApi.EnableFeatureByPackagePath(session, "NetFX3", null, true, true, new List<string>() { _mountedPath + @"\sources\sxs" }, delegate(DismProgress progress)
{
DismApi.Initialize(DismLogLevel.LogErrors);
using (var session = DismApi.OpenOnlineSession())
inProgress = true;
if (!indicatorStopped)
{
var stdout = GetStdHandle(-11);
bool indicatorStopped = false;
var maxHashTags = (ConsoleTUI.OpenFrame.DisplayWidth - 5);
DismApi.EnableFeatureByPackagePath(session, "NetFX3", null, true, true, new List<string>() { letter + @":\sources\sxs" }, delegate(DismProgress progress)
{
inProgress = true;
if (!indicatorStopped)
{
indicator.Stop();
Console.SetCursorPosition(leftCache, topCache);
Console.WriteLine(" ");
}
indicatorStopped = true;
var progressPerc = progress.Current / 10;
var currentHashTags = (int)Math.Ceiling(Math.Min(((double)progressPerc / 100) * maxHashTags, maxHashTags));
var spaces = maxHashTags - currentHashTags + (4 - progressPerc.ToString().Length);
var sb = new StringBuilder(new string('#', currentHashTags) + new string(' ', spaces) + progressPerc + "%");
uint throwaway;
WriteConsoleOutputCharacter(stdout, sb, (uint)sb.Length, new Languages.COORD((short)ConsoleTUI.OpenFrame.DisplayOffset, (short)Console.CursorTop), out throwaway);
inProgress = false;
});
session.Close();
Thread.Sleep(100);
var sb = new StringBuilder(new string('#', maxHashTags) + " 100%");
uint throwaway;
WriteConsoleOutputCharacter(stdout, sb, (uint)sb.Length, new Languages.COORD((short)ConsoleTUI.OpenFrame.DisplayOffset, (short)Console.CursorTop), out throwaway);
indicator.Stop();
Console.SetCursorPosition(leftCache, topCache);
Console.WriteLine(" ");
}
DismApi.Shutdown();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = "PowerShell.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = $"-NoP -C \"Dismount-DiskImage '{file}'\"";
startInfo.RedirectStandardOutput = true;
indicatorStopped = true;
var progressPercentage = progress.Current / 10;
var currentHashTags = (int)Math.Ceiling(Math.Min(((double)progressPercentage / 100) * maxHashTags, maxHashTags));
var spaces = maxHashTags - currentHashTags + (4 - progressPercentage.ToString().Length);
var sb = new StringBuilder(new string('#', currentHashTags) + new string(' ', spaces) + progressPercentage + "%");
WriteConsoleOutputCharacter(stdout, sb, (uint)sb.Length, new Languages.COORD((short)ConsoleTUI.OpenFrame.DisplayOffset, (short)Console.CursorTop), out _);
inProgress = false;
});
session.Close();
Thread.Sleep(100);
var sb = new StringBuilder(new string('#', maxHashTags) + " 100%");
uint throwaway;
WriteConsoleOutputCharacter(stdout, sb, (uint)sb.Length, new Languages.COORD((short)ConsoleTUI.OpenFrame.DisplayOffset, (short)Console.CursorTop), out throwaway);
}
var proc = Process.Start(startInfo);
proc.WaitForExit();
}
} catch (Exception e)
DismApi.Shutdown();
Unmount();
} catch (Exception e)
{
while (inProgress)
{
while (inProgress)
{
Thread.Sleep(50);
}
try
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = "PowerShell.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = $"-NoP -C \"Dismount-DiskImage '{file}'\"";
startInfo.RedirectStandardOutput = true;
var proc = Process.Start(startInfo);
proc.WaitForExit();
} catch (Exception ex)
{
}
Console.WriteLine();
Console.WriteLine();
ConsoleTUI.OpenFrame.Close("DISM error: " + e.Message, ConsoleColor.Red, Console.BackgroundColor, new ChoicePrompt()
{
AnyKey = true,
Text = "Press any key to return to the Menu: "
});
return false;
Thread.Sleep(50);
}
Unmount();
Console.WriteLine();
Console.WriteLine();
ConsoleTUI.OpenFrame.Close(".NET 3.5 installed successfully", ConsoleColor.Green, Console.BackgroundColor, new ChoicePrompt()
ConsoleTUI.OpenFrame.Close("DISM error: " + e.Message, ConsoleColor.Red, Console.BackgroundColor, new ChoicePrompt()
{
AnyKey = true,
Text = "Press any key to return to the Menu: "
});
return true;
return false;
}
else
Console.WriteLine();
Console.WriteLine();
ConsoleTUI.OpenFrame.Close(".NET 3.5 installed successfully", ConsoleColor.Green, Console.BackgroundColor, new ChoicePrompt()
{
Console.WriteLine();
ConsoleTUI.OpenFrame.Close("\r\nYou must select an ISO.", new ChoicePrompt() {AnyKey = true, Text = "Press any key to return to the Menu: "});
return true;
}
AnyKey = true,
Text = "Press any key to return to the Menu: "
});
return true;
}
[StructLayout(LayoutKind.Sequential)]


+ 239
- 0
src/Actions/Deameliorate.cs View File

@ -0,0 +1,239 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Security.Principal;
using System.Threading;
using amecs.Misc;
using Ameliorated.ConsoleUtils;
using Microsoft.Win32;
namespace amecs.Actions
{
public class Deameliorate
{
private static string _mountedPath;
private static string _winVer;
private static string _win11Setup = "";
private static bool _win11 = Environment.OSVersion.Version.Build >= 22000;
private const string ExplorerPatcherId = "D17F1E1A-5919-4427-8F89-A1A8503CA3EB";
public static bool DeAme()
{
if (new ChoicePrompt()
{
Text = @"
This will de-ameliorate by reinstalling Windows.
Although user data should be kept, we strongly recommend
making backups of any important user data.
Continue? (Y/N): "
}.Start().Value == 1) return true;
Program.Frame.Clear();
(_mountedPath, _, _winVer, _, _) = SelectWindowsImage.GetMediaPath();
if (_mountedPath == null) return false;
if (new ChoicePrompt {Text = $"\r\nYour Windows image is {_winVer}. Continue? (Y/N): "}.Start().Value == 1)
return true;
var fc = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Yellow;
string userSid = null;
try
{
NSudo.GetSystemPrivilege();
NSudo.RunAsUser(() =>
{
userSid = WindowsIdentity.GetCurrent().User.ToString();
});
}
catch
{
// do nothing
}
try
{
ConsoleTUI.OpenFrame.WriteCentered("\r\nUninstalling AME-installed UI software...");
string openShellId = null;
var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall");
foreach (var item in key.GetSubKeyNames())
{
try
{
if (((string)key.OpenSubKey(item).GetValue("DisplayName")).Equals("Open-Shell"))
openShellId = item;
}
catch
{
// do nothing
}
}
if (openShellId != null)
{
ConsoleTUI.OpenFrame.WriteCentered("\r\nUninstalling Open-Shell...");
Process.Start("MsiExec.exe", $"/X{openShellId} /quiet")?.WaitForExit();
if (userSid != null)
{
var appData = (string)Registry.Users.OpenSubKey(userSid + @"\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders").GetValue("AppData");
if (Directory.Exists(Path.Combine(appData, "OpenShell")))
Directory.Delete(Path.Combine(appData, "OpenShell"), true);
}
}
var epSetupPath = $@"{Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)}\ExplorerPatcher\ep_setup.exe";
if (File.Exists(epSetupPath))
{
ConsoleTUI.OpenFrame.WriteCentered("\r\nUninstalling ExplorerPatcher...");
var winlogon = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true);
winlogon?.SetValue("AutoRestartShell", 0);
// kill processes that the files use
foreach (var processName in new[] {"explorer.exe", "rundll32.exe", "dllhost.exe", "ShellExperienceHost.exe", "StartMenuExperienceHost.exe"})
{
foreach (var process in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(processName)))
{
process.Kill();
process.WaitForExit();
}
}
// delete DWM service that removes rounded corners
Process.Start("sc", $"stop \"ep_dwm_{ExplorerPatcherId}\"")?.WaitForExit();
Process.Start("sc", $"delete \"ep_dwm_{ExplorerPatcherId}\"")?.WaitForExit();
// remove registered DLL
var explorerPatcherDllPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "ExplorerPatcher", "ExplorerPatcher.amd64.dll");
Process.Start("regsvr32.exe", $"/s /u \"{explorerPatcherDllPath}\"")?.WaitForExit();
// delete files
foreach (var file in new[]
{
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows),
@"SystemApps\ShellExperienceHost_cw5n1h2txyewy\dxgi.dll"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows),
@"SystemApps\ShellExperienceHost_cw5n1h2txyewy\wincorlib.dll"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows),
@"SystemApps\ShellExperienceHost_cw5n1h2txyewy\wincorlib_orig.dll"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows),
@"SystemApps\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\dxgi.dll"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows),
@"SystemApps\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\wincorlib.dll"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows),
@"SystemApps\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\wincorlib_orig.dll"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows),
"dxgi.dll")
})
{
if (File.Exists(file)) File.Delete(file);
}
foreach (var folder in new[]
{
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
"ExplorerPatcher"),
Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
@"Microsoft\Windows\Start Menu\Programs\ExplorerPatcher")
})
{
if (Directory.Exists(folder)) Directory.Delete(folder, true);
}
winlogon?.SetValue("AutoRestartShell", 1);
}
Program.Frame.Clear();
} catch (Exception e)
{
ConsoleTUI.OpenFrame.Close(
"Error when uninstalling software: " + e.Message,
ConsoleColor.Red, Console.BackgroundColor,
new ChoicePrompt { AnyKey = true, Text = "Press any key to continue anyways: " });
Program.Frame.Clear();
ConsoleTUI.OpenFrame.WriteCentered("\r\nContinuing without uninstalling software...\r\n");
}
// restart Explorer
if (Process.GetProcessesByName("explorer").Length == 0)
NSudo.RunProcessAsUser(NSudo.GetUserToken(), "explorer.exe", "", 0);
// all policies are cleared as a user that's de-ameliorating is unlikely to have their own policies in the first place
// also clear ExplorerPatcher Registry entries
ConsoleTUI.OpenFrame.WriteCentered("\r\nClearing policies...");
foreach (var keyPath in new[] {
$@"HKU\{userSid}\Software\Microsoft\Windows\CurrentVersion\Policies",
$@"HKU\{userSid}\Software\Policies",
$@"HKU\{userSid}\Software\ExplorerPatcher",
$@"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{{ExplorerPatcherId}}}_ExplorerPatcher",
@"HKLM\Software\Microsoft\Windows\CurrentVersion\Policies",
@"HKLM\Software\Policies",
@"HKLM\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Policies"
})
{
var hive = RegistryHive.LocalMachine;
if (keyPath.StartsWith("HKU"))
hive = RegistryHive.Users;
var baseKey = RegistryKey.OpenBaseKey(hive, RegistryView.Default);
var subKeyPath = keyPath.Substring(keyPath.IndexOf('\\') + 1);
var key = baseKey.OpenSubKey(subKeyPath, true);
if (key == null) continue;
try
{
baseKey.DeleteSubKeyTree(subKeyPath);
}
catch
{
// do nothing - some values might fail, but almost all are deleted
}
key.Close();
}
Thread.Sleep(3000);
Program.Frame.Clear();
ConsoleTUI.OpenFrame.WriteCentered("\r\nCompleted initial setup!", ConsoleColor.Green);
if (_win11)
{
ConsoleTUI.OpenFrame.WriteCentered("\r\nWindows Setup will display as 'Windows Server,' but it's not actually installing Windows Server and is only set as such to bypass hardware requirements.");
Console.WriteLine();
}
ConsoleTUI.OpenFrame.WriteCentered("\r\nWaiting 10 seconds and starting Windows Setup...");
Console.ForegroundColor = fc;
Thread.Sleep(10000);
Console.WriteLine();
try
{
if (_win11) _win11Setup = "/Product Server";
Process.Start(Path.Combine(_mountedPath, "setup.exe"), $"/Auto Upgrade /DynamicUpdate Disable {_win11Setup}");
} catch (Exception e)
{
ConsoleTUI.OpenFrame.Close(
$"There was an error when trying to run the Windows Setup: {e}\r\nTry running the Windows Setup manually from File Explorer.",
ConsoleColor.Red, Console.BackgroundColor,
new ChoicePrompt { AnyKey = true, Text = $"Press any key to exit: " });
return false;
}
ConsoleTUI.OpenFrame.Close(
"Completed, Windows Setup should have started.",
ConsoleColor.Cyan, Console.BackgroundColor,
new ChoicePrompt { AnyKey = true, Text = $"Press any key to go back: " });
return true;
}
}
}

+ 11
- 0
src/Actions/Users.cs View File

@ -250,6 +250,17 @@ namespace amecs.Actions
var password = new InputPrompt() { MaskInput = true, Text = "\r\nEnter password for new user, or press\r\nescape to quit: " }.Start();
if (password == null)
return false;
var passwordConfirmation = new InputPrompt() { MaskInput = true, Text = "\r\nRe-enter your password, or press\r\nescape to quit: " }.Start();
if (passwordConfirmation == null)
return false;
if (password != passwordConfirmation)
{
ConsoleTUI.OpenFrame.WriteLine("The password re-entered does not match your original password.");
Console.WriteLine();
continue;
}
try
{


+ 1
- 0
src/Ameliorated.ConsoleUtils/ConsoleTUI/FrameWriteMethods.cs View File

@ -323,6 +323,7 @@ namespace Ameliorated.ConsoleUtils
ConsoleUtils.ResetColor();
}
// TODO: Fix this splitting lines when a piece of text can fit on one line
private List<CenteredString> CenterLines(string text, LineCenterOptions options, int maxWidth = 0)
{
var _maxWidth = DisplayWidth;


+ 4
- 4
src/Ameliorated.ConsoleUtils/ConsoleTUI/Menu.cs View File

@ -164,7 +164,7 @@ namespace Ameliorated.ConsoleUtils
while (true)
{
keyPressed = Console.ReadKey(true).Key;
if (keyPressed == ConsoleKey.DownArrow)
if (keyPressed == ConsoleKey.DownArrow || keyPressed == ConsoleKey.S)
{
if (validIndex >= currentValidChoices.Count - 1) continue;
Console.SetCursorPosition(Math.Max(TotalOffset - 2, 0), Console.CursorTop);
@ -182,7 +182,7 @@ namespace Ameliorated.ConsoleUtils
validIndex += 1;
}
if (keyPressed == ConsoleKey.UpArrow)
if (keyPressed == ConsoleKey.UpArrow || keyPressed == ConsoleKey.W)
{
if (!(validIndex > 0)) continue;
@ -201,7 +201,7 @@ namespace Ameliorated.ConsoleUtils
validIndex -= 1;
}
if (keyPressed == ConsoleKey.RightArrow || keyPressed == ConsoleKey.PageUp ||
if (keyPressed == ConsoleKey.RightArrow || keyPressed == ConsoleKey.A || keyPressed == ConsoleKey.PageUp ||
(keyPressed == ConsoleKey.Enter && currentValidChoices[validIndex].IsNextButton))
{
if (pageIndex == pages)
@ -245,7 +245,7 @@ namespace Ameliorated.ConsoleUtils
continue;
}
if (keyPressed == ConsoleKey.LeftArrow || keyPressed == ConsoleKey.PageDown ||
if (keyPressed == ConsoleKey.LeftArrow || keyPressed == ConsoleKey.D || keyPressed == ConsoleKey.PageDown ||
(keyPressed == ConsoleKey.Enter && currentValidChoices[validIndex].IsPreviousButton))
{
if (pageIndex == 1)


+ 10
- 0
src/App.config View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?><configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

+ 1
- 1
src/Globals.cs View File

@ -36,6 +36,6 @@ namespace amecs
return true;
}
public static readonly int WinVer = Int32.Parse(Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion").GetValue("CurrentBuildNumber").ToString());
public static readonly int WinVer = int.Parse(Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion").GetValue("CurrentBuildNumber").ToString());
}
}

+ 220
- 0
src/Misc/FolderPicker.cs View File

@ -0,0 +1,220 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
namespace amecs.Misc
{
public class FolderPicker
{
private readonly List<string> _resultPaths = new List<string>();
private readonly List<string> _resultNames = new List<string>();
public IReadOnlyList<string> ResultPaths => _resultPaths;
public IReadOnlyList<string> ResultNames => _resultNames;
public string ResultPath => ResultPaths.FirstOrDefault();
public string ResultName => ResultNames.FirstOrDefault();
public virtual string InputPath { get; set; }
public virtual bool ForceFileSystem { get; set; }
public virtual bool Multiselect { get; set; }
public virtual string Title { get; set; }
public virtual string OkButtonLabel { get; set; }
public virtual string FileNameLabel { get; set; }
protected virtual int SetOptions(int options)
{
if (ForceFileSystem)
{
options |= (int)FOS.FOS_FORCEFILESYSTEM;
}
if (Multiselect)
{
options |= (int)FOS.FOS_ALLOWMULTISELECT;
}
return options;
}
// for all .NET
public virtual bool? ShowDialog(IntPtr owner, bool throwOnError = false)
{
var dialog = (IFileOpenDialog)new FileOpenDialog();
if (!string.IsNullOrEmpty(InputPath))
{
if (CheckHr(SHCreateItemFromParsingName(InputPath, null, typeof(IShellItem).GUID, out var item), throwOnError) != 0)
return null;
dialog.SetFolder(item);
}
var options = FOS.FOS_PICKFOLDERS;
options = (FOS)SetOptions((int)options);
dialog.SetOptions(options);
if (Title != null)
{
dialog.SetTitle(Title);
}
if (OkButtonLabel != null)
{
dialog.SetOkButtonLabel(OkButtonLabel);
}
if (FileNameLabel != null)
{
dialog.SetFileName(FileNameLabel);
}
if (owner == IntPtr.Zero)
{
owner = Process.GetCurrentProcess().MainWindowHandle;
if (owner == IntPtr.Zero)
{
owner = GetDesktopWindow();
}
}
var hr = dialog.Show(owner);
if (hr == ERROR_CANCELLED)
return null;
if (CheckHr(hr, throwOnError) != 0)
return null;
if (CheckHr(dialog.GetResults(out var items), throwOnError) != 0)
return null;
items.GetCount(out var count);
for (var i = 0; i < count; i++)
{
items.GetItemAt(i, out var item);
CheckHr(item.GetDisplayName(SIGDN.SIGDN_DESKTOPABSOLUTEPARSING, out var path), throwOnError);
CheckHr(item.GetDisplayName(SIGDN.SIGDN_DESKTOPABSOLUTEEDITING, out var name), throwOnError);
if (path != null || name != null)
{
_resultPaths.Add(path);
_resultNames.Add(name);
}
}
return true;
}
private static int CheckHr(int hr, bool throwOnError)
{
if (hr != 0 && throwOnError) Marshal.ThrowExceptionForHR(hr);
return hr;
}
[DllImport("shell32")]
private static extern int SHCreateItemFromParsingName([MarshalAs(UnmanagedType.LPWStr)] string pszPath, IBindCtx pbc, [MarshalAs(UnmanagedType.LPStruct)] Guid riid, out IShellItem ppv);
[DllImport("user32")]
private static extern IntPtr GetDesktopWindow();
#pragma warning disable IDE1006 // Naming Styles
private const int ERROR_CANCELLED = unchecked((int)0x800704C7);
#pragma warning restore IDE1006 // Naming Styles
[ComImport, Guid("DC1C5A9C-E88A-4dde-A5A1-60F82A20AEF7")] // CLSID_FileOpenDialog
private class FileOpenDialog { }
[ComImport, Guid("d57c7288-d4ad-4768-be02-9d969532d960"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
private interface IFileOpenDialog
{
[PreserveSig] int Show(IntPtr parent); // IModalWindow
[PreserveSig] int SetFileTypes(); // not fully defined
[PreserveSig] int SetFileTypeIndex(int iFileType);
[PreserveSig] int GetFileTypeIndex(out int piFileType);
[PreserveSig] int Advise(); // not fully defined
[PreserveSig] int Unadvise();
[PreserveSig] int SetOptions(FOS fos);
[PreserveSig] int GetOptions(out FOS pfos);
[PreserveSig] int SetDefaultFolder(IShellItem psi);
[PreserveSig] int SetFolder(IShellItem psi);
[PreserveSig] int GetFolder(out IShellItem ppsi);
[PreserveSig] int GetCurrentSelection(out IShellItem ppsi);
[PreserveSig] int SetFileName([MarshalAs(UnmanagedType.LPWStr)] string pszName);
[PreserveSig] int GetFileName([MarshalAs(UnmanagedType.LPWStr)] out string pszName);
[PreserveSig] int SetTitle([MarshalAs(UnmanagedType.LPWStr)] string pszTitle);
[PreserveSig] int SetOkButtonLabel([MarshalAs(UnmanagedType.LPWStr)] string pszText);
[PreserveSig] int SetFileNameLabel([MarshalAs(UnmanagedType.LPWStr)] string pszLabel);
[PreserveSig] int GetResult(out IShellItem ppsi);
[PreserveSig] int AddPlace(IShellItem psi, int alignment);
[PreserveSig] int SetDefaultExtension([MarshalAs(UnmanagedType.LPWStr)] string pszDefaultExtension);
[PreserveSig] int Close(int hr);
[PreserveSig] int SetClientGuid(); // not fully defined
[PreserveSig] int ClearClientData();
[PreserveSig] int SetFilter([MarshalAs(UnmanagedType.IUnknown)] object pFilter);
[PreserveSig] int GetResults(out IShellItemArray ppenum);
[PreserveSig] int GetSelectedItems([MarshalAs(UnmanagedType.IUnknown)] out object ppsai);
}
[ComImport, Guid("43826D1E-E718-42EE-BC55-A1E261C37BFE"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
private interface IShellItem
{
[PreserveSig] int BindToHandler(); // not fully defined
[PreserveSig] int GetParent(); // not fully defined
[PreserveSig] int GetDisplayName(SIGDN sigdnName, [MarshalAs(UnmanagedType.LPWStr)] out string ppszName);
[PreserveSig] int GetAttributes(); // not fully defined
[PreserveSig] int Compare(); // not fully defined
}
[ComImport, Guid("b63ea76d-1f85-456f-a19c-48159efa858b"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
private interface IShellItemArray
{
[PreserveSig] int BindToHandler(); // not fully defined
[PreserveSig] int GetPropertyStore(); // not fully defined
[PreserveSig] int GetPropertyDescriptionList(); // not fully defined
[PreserveSig] int GetAttributes(); // not fully defined
[PreserveSig] int GetCount(out int pdwNumItems);
[PreserveSig] int GetItemAt(int dwIndex, out IShellItem ppsi);
[PreserveSig] int EnumItems(); // not fully defined
}
#pragma warning disable CA1712 // Do not prefix enum values with type name
private enum SIGDN : uint
{
SIGDN_DESKTOPABSOLUTEEDITING = 0x8004c000,
SIGDN_DESKTOPABSOLUTEPARSING = 0x80028000,
SIGDN_FILESYSPATH = 0x80058000,
SIGDN_NORMALDISPLAY = 0,
SIGDN_PARENTRELATIVE = 0x80080001,
SIGDN_PARENTRELATIVEEDITING = 0x80031001,
SIGDN_PARENTRELATIVEFORADDRESSBAR = 0x8007c001,
SIGDN_PARENTRELATIVEPARSING = 0x80018001,
SIGDN_URL = 0x80068000
}
[Flags]
private enum FOS
{
FOS_OVERWRITEPROMPT = 0x2,
FOS_STRICTFILETYPES = 0x4,
FOS_NOCHANGEDIR = 0x8,
FOS_PICKFOLDERS = 0x20,
FOS_FORCEFILESYSTEM = 0x40,
FOS_ALLNONSTORAGEITEMS = 0x80,
FOS_NOVALIDATE = 0x100,
FOS_ALLOWMULTISELECT = 0x200,
FOS_PATHMUSTEXIST = 0x800,
FOS_FILEMUSTEXIST = 0x1000,
FOS_CREATEPROMPT = 0x2000,
FOS_SHAREAWARE = 0x4000,
FOS_NOREADONLYRETURN = 0x8000,
FOS_NOTESTFILECREATE = 0x10000,
FOS_HIDEMRUPLACES = 0x20000,
FOS_HIDEPINNEDPLACES = 0x40000,
FOS_NODEREFERENCELINKS = 0x100000,
FOS_OKBUTTONNEEDSINTERACTION = 0x200000,
FOS_DONTADDTORECENT = 0x2000000,
FOS_FORCESHOWHIDDEN = 0x10000000,
FOS_DEFAULTNOMINIMODE = 0x20000000,
FOS_FORCEPREVIEWPANEON = 0x40000000,
FOS_SUPPORTSTREAMABLEITEMS = unchecked((int)0x80000000)
}
#pragma warning restore CA1712 // Do not prefix enum values with type name
}
}

+ 261
- 0
src/Misc/SelectWindowsImage.cs View File

@ -0,0 +1,261 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Security;
using System.Windows.Forms;
using Ameliorated.ConsoleUtils;
using Microsoft.Dism;
// Asks user to select Windows installation media, and mounts it if applicable
// Returns path to where it's mounted
namespace amecs.Misc
{
public static class SelectWindowsImage
{
private static string _fileViolationTest;
private static bool CheckFileViolation(string inputFile)
{
try
{
_fileViolationTest = inputFile;
}
catch (SecurityException e)
{
Console.WriteLine();
ConsoleTUI.OpenFrame.Close("Security exception: " + e.Message, ConsoleColor.Red, Console.BackgroundColor, new ChoicePrompt { AnyKey = true, Text = "Press any key to return to the Menu: " });
return true;
}
return false;
}
public static string GetWindowsVersion(float majorMinor, int isoBuild)
{
return (majorMinor, isoBuild) switch
{
(6, _) => "Windows Vista",
(6.1f, _) => "Windows 7",
(6.2f, _) => "Windows 8",
(6.3f, _) => "Windows 8.1",
(10, var a) when a < 19041 => "Windows 10 (Old)",
(10, var a) when a >= 22000 => "Windows 11",
(10, _) => "Windows 10",
_ => "Unknown"
};
}
public static bool DismountIso(string imagePath)
{
var startInfo = new ProcessStartInfo
{
CreateNoWindow = false,
UseShellExecute = false,
FileName = "PowerShell.exe",
WindowStyle = ProcessWindowStyle.Hidden,
Arguments = $"-NoP -C \"Dismount-DiskImage '{imagePath}'\"",
RedirectStandardOutput = true
};
var proc = Process.Start(startInfo);
if (proc == null) return false;
proc.WaitForExit();
return true;
}
private static string _mountedPath;
private static string _isoPath;
private static string _isoWinVer;
private static int _isoBuild;
/// <summary>
/// Asks user to select Windows installation media, mounts it if applicable, and checks its version
/// </summary>
/// <param name="winVersionsMustMatch">If true when ISO and host versions mismatch, prompts user that things can break if they continue</param>
/// <param name="isoBuildMustBeReturned">If true and the ISO build can't be retrieved, prompts a user with an error</param>
public static (
string MountedPath, string IsoPath, string Winver, int? Build, bool? VersionsMatch
) GetMediaPath(bool winVersionsMustMatch = false, bool isoBuildMustBeReturned = false)
{
var error = ((string)null, "none", (string)null, (int?)null, (bool?)null);
var choice =
new ChoicePrompt { Text = "To continue, Windows installation media is needed.\r\nDo you have a Windows USB instead of an ISO file? (Y/N): " }.Start();
if (!choice.HasValue) return error;
// Folder/drive chosen
var usingFolder = choice == 0;
if (usingFolder)
{
var dlg = new FolderPicker
{
InputPath = Globals.UserFolder
};
if (dlg.ShowDialog(IntPtr.Zero).GetValueOrDefault())
{
if (CheckFileViolation(dlg.ResultPath))
return error;
_mountedPath = dlg.ResultPath;
}
else
{
Console.WriteLine();
ConsoleTUI.OpenFrame.Close("\r\nYou must select a folder or drive containing Windows installation media.",
new ChoicePrompt { AnyKey = true, Text = "Press any key to return to the Menu: " });
return error;
}
}
else
{
// Mounting the ISO
var dialog = new OpenFileDialog();
dialog.Filter = "ISO Files (*.ISO)| *.ISO";
dialog.Multiselect = false;
dialog.InitialDirectory = Globals.UserFolder;
var window = new NativeWindow();
window.AssignHandle(Process.GetCurrentProcess().MainWindowHandle);
if (dialog.ShowDialog(window) == DialogResult.OK)
{
_isoPath = dialog.FileName;
if (CheckFileViolation(_isoPath)) return error;
Console.WriteLine();
ConsoleTUI.OpenFrame.WriteCentered("\r\nMounting ISO");
}
else
{
Console.WriteLine();
ConsoleTUI.OpenFrame.Close("\r\nYou must select an ISO.",
new ChoicePrompt { AnyKey = true, Text = "Press any key to return to the Menu: " });
return error;
}
using (new ConsoleUtils.LoadingIndicator(true))
{
var startInfo = new ProcessStartInfo
{
CreateNoWindow = false,
UseShellExecute = false,
FileName = "PowerShell.exe",
WindowStyle = ProcessWindowStyle.Hidden,
Arguments = $"-NoP -C \"(Mount-DiskImage '{_isoPath}' -PassThru | Get-Volume).DriveLetter + ':\'\"",
RedirectStandardOutput = true
};
var proc = Process.Start(startInfo);
if (proc == null) return error;
proc.WaitForExit();
_mountedPath = proc.StandardOutput.ReadLine();
}
}
// Check WIM version
var wimOrEsdPath = new[] { $@"{_mountedPath}\sources\install.esd", $@"{_mountedPath}\sources\install.wim" }.FirstOrDefault(File.Exists);
if (!string.IsNullOrEmpty(wimOrEsdPath))
{
try
{
DismApi.Initialize(DismLogLevel.LogErrors);
string previousIndexVersion = null;
string isoFullVersion = null;
var multiVersion = false;
var imageInfos = DismApi.GetImageInfo(wimOrEsdPath);
foreach (var imageInfo in imageInfos)
{
isoFullVersion = imageInfo.ProductVersion.ToString();
if (isoFullVersion != previousIndexVersion && previousIndexVersion != null)
{
// If it's multi-version, WinVer will be "Unknown" as well
multiVersion = true;
isoFullVersion = "0.0.0.0";
break;
}
previousIndexVersion = isoFullVersion;
}
switch (multiVersion)
{
case true when isoBuildMustBeReturned:
ConsoleTUI.OpenFrame.Close(
"Multiple Windows versions were found in the Windows image, can't determine which Windows build it is. Please use an unmodified Windows ISO.",
ConsoleColor.Red, Console.BackgroundColor,
new ChoicePrompt { AnyKey = true, Text = "Press any key to return to the Menu: " });
return error;
case true when winVersionsMustMatch:
ConsoleTUI.OpenFrame.Close(
"Multiple Windows versions were found in the Windows image, can't determine which Windows build it is. If your Windows version doesn't match the ISO, there will be problems.",
ConsoleColor.Red, Console.BackgroundColor,
new ChoicePrompt { AnyKey = true, Text = "Press any key to continue anyways: " });
Program.Frame.Clear();
ConsoleTUI.OpenFrame.WriteCentered("\r\nContinuing without version check...\r\n");
break;
}
var buildSplit = isoFullVersion.Split('.');
_isoBuild = int.Parse(buildSplit[2]);
_isoWinVer = GetWindowsVersion(float.Parse($"{buildSplit[0]}.{buildSplit[1]}"), _isoBuild);
}
catch (Exception e)
{
Console.WriteLine();
ConsoleTUI.OpenFrame.Close(
"Error checking ISO version: " + e.Message.TrimEnd('\n').TrimEnd('\r'),
ConsoleColor.Red, Console.BackgroundColor,
new ChoicePrompt { AnyKey = true, Text = "Press any key to return to the Menu: " });
return error;
}
finally
{
try
{
DismApi.Shutdown();
}
catch
{
// do nothing
}
}
// Check the current OS version
var hostVersion = Environment.OSVersion.Version;
var hostWinver = GetWindowsVersion(float.Parse($"{hostVersion.Major}.{hostVersion.Minor}"), hostVersion.Build);
// If it all matches & winVersionsMustMatch
if (hostWinver == _isoWinVer) return (_mountedPath, _isoPath, _isoWinVer, _isoBuild, true);
// If ISO version doesn't match host version & winVersionsMustMatch
if (hostWinver != _isoWinVer && winVersionsMustMatch)
{
if (!string.IsNullOrEmpty(_isoPath)) DismountIso(_isoPath);
ConsoleTUI.OpenFrame.Close(
$"You're on {hostWinver}, but the selected image is {_isoWinVer}. You can only use an ISO that matches your Windows version.",
ConsoleColor.Red, Console.BackgroundColor,
new ChoicePrompt { AnyKey = true, Text = "Press any key to return to the Menu: " });
return error;
}
// If ISO version doesn't match host version, and winVersionsMustMatch is true
if (hostWinver != _isoWinVer) return (_mountedPath, _isoPath, _isoWinVer, _isoBuild, false);
}
var noWimText = isoBuildMustBeReturned
? "Press any key to return to the Menu"
: "Press any key to continue anyways";
ConsoleTUI.OpenFrame.Close(
"No Windows installation image was found inside the selected Windows media. No version check can be done, things might break.",
ConsoleColor.Red, Console.BackgroundColor,
new ChoicePrompt { AnyKey = true, Text = $"{noWimText}: " });
Program.Frame.Clear();
ConsoleTUI.OpenFrame.WriteCentered("\r\nContinuing without version check\r\n");
return isoBuildMustBeReturned ? error : (_mountedPath, _isoPath, null, null, null);
}
}
}

+ 15
- 2
src/NSudo.cs View File

@ -6,6 +6,7 @@ using System.Runtime.InteropServices;
using System.Security;
using System.Security.Principal;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Win32.SafeHandles;
namespace amecs
@ -505,8 +506,20 @@ namespace amecs
RtlAdjustPrivilege((int)luid, true, true, out throwaway);
}
public class Win32 {
public static void RunAsUser(Action action)
{
var token = NSudo.GetUserToken();
Task.Run((Action)Delegate.Combine((Action)(() => { NSudo.GetUserPrivilege(token); }),
action)).Wait();
Marshal.FreeHGlobal(token);
}
private static async Task RunAsUserAsync(Action action)
{
var token = NSudo.GetUserToken();
await Task.Run((Action)Delegate.Combine((Action)(() => { NSudo.GetUserPrivilege(token); }),
action));
Marshal.FreeHGlobal(token);
}
}
}

+ 6
- 33
src/Program.cs View File

@ -1,19 +1,9 @@
using System;
using System.Diagnostics;
using System.DirectoryServices;
using System.DirectoryServices.AccountManagement;
using System.Globalization;
using System.Linq;
using System.Management;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Principal;
using System.Threading;
using System.Threading.Tasks;
using Ameliorated.ConsoleUtils;
using Microsoft.Win32;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
using amecs.Actions;
using Menu = Ameliorated.ConsoleUtils.Menu;
@ -21,28 +11,11 @@ namespace amecs
{
internal class Program
{
private static void RunAsUser(Action action)
{
var token = NSudo.GetUserToken();
Task.Run((Action)Delegate.Combine((Action)(() => { NSudo.GetUserPrivilege(token); }),
action)).Wait();
Marshal.FreeHGlobal(token);
}
private static async Task RunAsUserAsync(Action action)
{
var token = NSudo.GetUserToken();
await Task.Run((Action)Delegate.Combine((Action)(() => { NSudo.GetUserPrivilege(token); }),
action));
Marshal.FreeHGlobal(token);
}
private const string Ver = "2.1";
public static ConsoleTUI.Frame Frame;
public static async Task Main(string[] args)
[STAThread]
public static void Main(string[] args)
{
ConsoleTUI.Initialize("Central AME Script");
@ -51,7 +24,7 @@ namespace amecs
NSudo.GetSystemPrivilege();
if (!WindowsIdentity.GetCurrent().IsSystem)
throw new Exception("Identity did not change.");
RunAsUser(() =>
NSudo.RunAsUser(() =>
{
Globals.Username = WindowsIdentity.GetCurrent().Name.Split('\\').Last();
Globals.UserDomain = WindowsIdentity.GetCurrent().Name.Split('\\').FirstOrDefault();
@ -82,9 +55,8 @@ namespace amecs
}
Frame = new ConsoleTUI.Frame($"| Central AME Script v{Ver} |", false);
Frame.Open();
while (true)
{
Globals.UserElevated = Globals.User.IsMemberOf(Globals.Administrators);
@ -137,6 +109,7 @@ namespace amecs
new Menu.MenuItem("Install .NET 3.5", new Func<bool>(_NET.Install)) :
new Menu.MenuItem("Install .NET 3.5", new Func<bool>(_NET.Install)) {SecondaryText = "[Installed]", SecondaryTextForeground = ConsoleColor.Yellow, PrimaryTextForeground = ConsoleColor.DarkGray},
Menu.MenuItem.Blank,
new Menu.MenuItem("Uninstall AME", new Func<bool>(Deameliorate.DeAme)),
new Menu.MenuItem("Extra", new Func<bool>(Extra.Extra.ShowMenu)),
new Menu.MenuItem("Exit", new Func<bool>(Globals.Exit))
},


+ 42
- 27
src/amecs.csproj View File

@ -5,6 +5,7 @@
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationIcon>amecs.ico</ApplicationIcon>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -39,19 +40,17 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32bit>false</Prefer32bit>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="Costura, Version=5.7.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Costura.Fody.5.7.0\lib\netstandard1.0\Costura.dll</HintPath>
</Reference>
<Reference Include="JetBrains.Annotations, Version=4242.42.42.42, Culture=neutral, PublicKeyToken=1010a0d8d6380325, processorArchitecture=MSIL">
<HintPath>packages\JetBrains.Annotations.2022.3.1\lib\net20\JetBrains.Annotations.dll</HintPath>
<Private>False</Private>
<HintPath>packages\JetBrains.Annotations.2023.3.0\lib\net20\JetBrains.Annotations.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Dism, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5bba90053b345501, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Dism.2.5.2\lib\net40\Microsoft.Dism.dll</HintPath>
<HintPath>packages\Microsoft.Dism.3.1.0\lib\net40\Microsoft.Dism.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Win32.Primitives, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Win32.Primitives.4.3.0\lib\net46\Microsoft.Win32.Primitives.dll</HintPath>
@ -61,20 +60,22 @@
<Reference Include="System.AppContext, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.AppContext.4.3.0\lib\net463\System.AppContext.dll</HintPath>
</Reference>
<Reference Include="System.CodeDom, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.CodeDom.7.0.0\lib\net462\System.CodeDom.dll</HintPath>
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.CodeDom, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.CodeDom.8.0.0\lib\net462\System.CodeDom.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Configuration" />
<Reference Include="System.Console, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Console.4.3.0\lib\net46\System.Console.dll</HintPath>
<Reference Include="System.Console, Version=4.0.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Console.4.3.1\lib\net46\System.Console.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Data.OracleClient" />
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Diagnostics.DiagnosticSource.4.3.0\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
<Private>False</Private>
<Reference Include="System.Diagnostics.DiagnosticSource, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Diagnostics.DiagnosticSource.8.0.0\lib\net462\System.Diagnostics.DiagnosticSource.dll</HintPath>
</Reference>
<Reference Include="System.Diagnostics.Tracing, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Diagnostics.Tracing.4.3.0\lib\net462\System.Diagnostics.Tracing.dll</HintPath>
@ -115,22 +116,31 @@
<HintPath>packages\System.Linq.Expressions.4.3.0\lib\net463\System.Linq.Expressions.dll</HintPath>
</Reference>
<Reference Include="System.Management" />
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Net" />
<Reference Include="System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Net.Http.4.3.0\lib\net46\System.Net.Http.dll</HintPath>
<Reference Include="System.Net.Http, Version=4.1.1.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll</HintPath>
</Reference>
<Reference Include="System.Net.Sockets, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Net.Sockets.4.3.0\lib\net46\System.Net.Sockets.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Reflection, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll</HintPath>
</Reference>
<Reference Include="System.Runtime, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll</HintPath>
<Reference Include="System.Runtime, Version=4.1.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.4.3.1\lib\net462\System.Runtime.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Extensions, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll</HintPath>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Extensions, Version=4.1.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.Extensions.4.3.1\lib\net462\System.Runtime.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.InteropServices, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dll</HintPath>
@ -144,7 +154,7 @@
<Private>False</Private>
</Reference>
<Reference Include="System.Security.Cryptography.Algorithms, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll</HintPath>
<HintPath>packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net463\System.Security.Cryptography.Algorithms.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.Encoding, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath>
@ -152,12 +162,11 @@
<Reference Include="System.Security.Cryptography.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.X509Certificates, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
<Reference Include="System.Security.Cryptography.X509Certificates, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Security.Cryptography.X509Certificates.4.3.2\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
</Reference>
<Reference Include="System.Security.Permissions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Security.Permissions.7.0.0\lib\net462\System.Security.Permissions.dll</HintPath>
<Private>False</Private>
<Reference Include="System.Security.Permissions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Security.Permissions.8.0.0\lib\net462\System.Security.Permissions.dll</HintPath>
</Reference>
<Reference Include="System.Security.Principal.Windows, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll</HintPath>
@ -165,20 +174,21 @@
</Reference>
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Text.RegularExpressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Text.RegularExpressions.4.3.0\lib\net463\System.Text.RegularExpressions.dll</HintPath>
<HintPath>packages\System.Text.RegularExpressions.4.3.1\lib\net463\System.Text.RegularExpressions.dll</HintPath>
</Reference>
<Reference Include="System.Transactions" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml.ReaderWriter, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll</HintPath>
<HintPath>packages\System.Xml.ReaderWriter.4.3.1\lib\net46\System.Xml.ReaderWriter.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Actions\.NET.cs" />
<Compile Include="Actions\AutoLogon.cs" />
<Compile Include="Actions\Deameliorate.cs" />
<Compile Include="Actions\Elevation.cs" />
<Compile Include="Actions\Languages.cs" />
<Compile Include="Actions\Lockscreen.cs" />
@ -201,6 +211,8 @@
<Compile Include="Extra\NVCP.cs" />
<Compile Include="Extra\WSH.cs" />
<Compile Include="Globals.cs" />
<Compile Include="Misc\FolderPicker.cs" />
<Compile Include="Misc\SelectWindowsImage.cs" />
<Compile Include="NSudo.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@ -209,6 +221,7 @@
<ItemGroup>
<None Include="amecs.ico" />
<None Include="amecs.png" />
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
@ -230,16 +243,18 @@
</COMReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="packages\Fody.6.5.5\build\Fody.targets" Condition="Exists('packages\Fody.6.5.5\build\Fody.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\Fody.6.5.5\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Fody.6.5.5\build\Fody.targets'))" />
<Error Condition="!Exists('packages\Costura.Fody.5.7.0\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Costura.Fody.5.7.0\build\Costura.Fody.props'))" />
<Error Condition="!Exists('packages\Costura.Fody.5.7.0\build\Costura.Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Costura.Fody.5.7.0\build\Costura.Fody.targets'))" />
<Error Condition="!Exists('packages\Fody.6.8.0\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Fody.6.8.0\build\Fody.targets'))" />
<Error Condition="!Exists('packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets'))" />
</Target>
<Import Project="packages\Costura.Fody.5.7.0\build\Costura.Fody.targets" Condition="Exists('packages\Costura.Fody.5.7.0\build\Costura.Fody.targets')" />
<Import Project="packages\Fody.6.8.0\build\Fody.targets" Condition="Exists('packages\Fody.6.8.0\build\Fody.targets')" />
<Import Project="packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">


+ 7
- 0
src/app.manifest View File

@ -7,4 +7,11 @@
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Support Windows 10 and above - needed for certain functions to return
correct Windows version. https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests#supportedOS -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
</assembly>

+ 24
- 20
src/packages.config View File

@ -1,23 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Costura.Fody" version="5.7.0" targetFramework="net472" developmentDependency="true" />
<package id="Fody" version="6.5.5" targetFramework="net472" developmentDependency="true" />
<package id="JetBrains.Annotations" version="2022.3.1" targetFramework="net472" />
<package id="Microsoft.Dism" version="2.5.2" targetFramework="net472" />
<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net472" />
<package id="Fody" version="6.8.0" targetFramework="net472" developmentDependency="true" />
<package id="JetBrains.Annotations" version="2023.3.0" targetFramework="net472" />
<package id="Microsoft.Dism" version="3.1.0" targetFramework="net472" />
<package id="Microsoft.NETCore.Platforms" version="7.0.4" targetFramework="net472" />
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net472" />
<package id="NETStandard.Library" version="1.6.1" targetFramework="net472" />
<package id="NETStandard.Library" version="2.0.3" targetFramework="net472" />
<package id="System.AppContext" version="4.3.0" targetFramework="net472" />
<package id="System.CodeDom" version="7.0.0" targetFramework="net472" />
<package id="System.CodeDom" version="8.0.0" targetFramework="net472" />
<package id="System.Console" version="4.3.1" targetFramework="net472" />
<package id="System.Diagnostics.DiagnosticSource" version="8.0.0" targetFramework="net472" />
<package id="System.DirectoryServices" version="8.0.0" targetFramework="net472" />
<package id="System.DirectoryServices.AccountManagement" version="8.0.0" targetFramework="net472" />
<package id="System.Management" version="8.0.0" targetFramework="net472" />
<package id="System.Net.Http" version="4.3.4" targetFramework="net472" />
<package id="System.Runtime.Extensions" version="4.3.1" targetFramework="net472" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.1" targetFramework="net472" />
<package id="System.Security.Cryptography.X509Certificates" version="4.3.2" targetFramework="net472" />
<package id="System.Security.Permissions" version="8.0.0" targetFramework="net472" />
<package id="System.Text.RegularExpressions" version="4.3.1" targetFramework="net472" />
<package id="System.Xml.ReaderWriter" version="4.3.1" targetFramework="net472" />
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
<package id="System.Net.Primitives" version="4.3.1" targetFramework="net472" />
<package id="System.Runtime" version="4.3.1" targetFramework="net472" />
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
<package id="System.Collections" version="4.3.0" targetFramework="net472" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net472" />
<package id="System.Console" version="4.3.0" targetFramework="net472" />
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net472" />
<package id="System.Diagnostics.DiagnosticSource" version="4.3.0" targetFramework="net472" />
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net472" />
<package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="net472" />
<package id="System.DirectoryServices" version="7.0.1" targetFramework="net472" />
<package id="System.DirectoryServices.AccountManagement" version="7.0.0" targetFramework="net472" />
<package id="System.Drawing.Primitives" version="4.3.0" targetFramework="net472" />
<package id="System.Globalization" version="4.3.0" targetFramework="net472" />
<package id="System.Globalization.Calendars" version="4.3.0" targetFramework="net472" />
@ -29,34 +41,26 @@
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net472" />
<package id="System.Linq" version="4.3.0" targetFramework="net472" />
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="net472" />
<package id="System.Management" version="7.0.0" targetFramework="net472" />
<package id="System.Net.Http" version="4.3.0" targetFramework="net472" />
<package id="System.Net.Primitives" version="4.3.0" targetFramework="net472" />
<package id="System.Net.Sockets" version="4.3.0" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.ObjectModel" version="4.3.0" targetFramework="net472" />
<package id="System.Reflection" version="4.3.0" targetFramework="net472" />
<package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net472" />
<package id="System.Reflection.Primitives" version="4.3.0" targetFramework="net472" />
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
<package id="System.Runtime.Handles" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net472" />
<package id="System.Security.AccessControl" version="6.0.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Permissions" version="7.0.0" targetFramework="net472" />
<package id="System.Security.Principal.Windows" version="5.0.0" targetFramework="net472" />
<package id="System.Text.Encoding" version="4.3.0" targetFramework="net472" />
<package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net472" />
<package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net472" />
<package id="System.Threading" version="4.3.0" targetFramework="net472" />
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="net472" />
<package id="System.Threading.Timer" version="4.3.0" targetFramework="net472" />
<package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net472" />
<package id="System.Xml.XDocument" version="4.3.0" targetFramework="net472" />
</packages>

Loading…
Cancel
Save