22 Commits
v1.4 ... master

45 changed files with 8499 additions and 4030 deletions
Split View
  1. +559
    -0
      .gitignore
  2. +22
    -82
      README.md
  3. +0
    -3948
      amecs.cmd
  4. BIN
      screenshot.png
  5. BIN
      src/7z.dll
  6. +132
    -0
      src/Actions/.NET.cs
  7. +313
    -0
      src/Actions/AutoLogon.cs
  8. +239
    -0
      src/Actions/Deameliorate.cs
  9. +21
    -0
      src/Actions/Elevation.cs
  10. +1089
    -0
      src/Actions/Languages.cs
  11. +113
    -0
      src/Actions/Lockscreen.cs
  12. +124
    -0
      src/Actions/Profile.cs
  13. +220
    -0
      src/Actions/UserPass.cs
  14. +19
    -0
      src/Actions/UsernameRequirement.cs
  15. +299
    -0
      src/Actions/Users.cs
  16. +201
    -0
      src/Ameliorated.ConsoleUtils/ConsoleTUI/ConsoleTUI.cs
  17. +198
    -0
      src/Ameliorated.ConsoleUtils/ConsoleTUI/Frame.cs
  18. +397
    -0
      src/Ameliorated.ConsoleUtils/ConsoleTUI/FrameWriteMethods.cs
  19. +433
    -0
      src/Ameliorated.ConsoleUtils/ConsoleTUI/Menu.cs
  20. +196
    -0
      src/Ameliorated.ConsoleUtils/ConsoleTUI/MouseInterface.cs
  21. +604
    -0
      src/Ameliorated.ConsoleUtils/ConsoleTUI/Prompt.cs
  22. +250
    -0
      src/Ameliorated.ConsoleUtils/ConsoleUtils.cs
  23. +88
    -0
      src/Ameliorated.ConsoleUtils/Extensions.cs
  24. +74
    -0
      src/Ameliorated.ConsoleUtils/ParentProcess.cs
  25. +6
    -0
      src/Ameliorated.ConsoleUtils/Payload.cs
  26. +10
    -0
      src/App.config
  27. +342
    -0
      src/Extra/Extra.cs
  28. +281
    -0
      src/Extra/NVCP.cs
  29. +40
    -0
      src/Extra/WSH.cs
  30. +3
    -0
      src/FodyWeavers.xml
  31. +41
    -0
      src/Globals.cs
  32. +220
    -0
      src/Misc/FolderPicker.cs
  33. +261
    -0
      src/Misc/SelectWindowsImage.cs
  34. +525
    -0
      src/NSudo.cs
  35. +141
    -0
      src/Program.cs
  36. +35
    -0
      src/Properties/AssemblyInfo.cs
  37. +375
    -0
      src/Registry.cs
  38. +263
    -0
      src/amecs.cs
  39. +266
    -0
      src/amecs.csproj
  40. BIN
      src/amecs.ico
  41. BIN
      src/amecs.png
  42. +16
    -0
      src/amecs.sln
  43. BIN
      src/amecs_old.ico
  44. +17
    -0
      src/app.manifest
  45. +66
    -0
      src/packages.config

+ 559
- 0
.gitignore View File

@ -0,0 +1,559 @@
!*.gitkeep
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Nuget personal access tokens and Credentials
nuget.config
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp
# JetBrains Rider
.idea/
*.sln.iml
### Git ###
# Created by git for backups. To disable backups in Git:
# $ git config --global mergetool.keepBackup false
*.orig
# Created by git when using merge tools for conflicts
*.BACKUP.*
*.BASE.*
*.LOCAL.*
*.REMOTE.*
*_BACKUP_*.txt
*_BASE_*.txt
*_LOCAL_*.txt
*_REMOTE_*.txt
### vs ###
# User-specific files
# User-specific files (MonoDevelop/Xamarin Studio)
# Mono auto generated files
# Build results
# Visual Studio 2015/2017 cache/options directory
# Uncomment if you have tasks that create the project's static files in wwwroot
# Visual Studio 2017 auto generated files
# MSTest test Results
# NUnit
# Build Results of an ATL Project
# Benchmark Results
# .NET Core
# StyleCop
# Files built by Visual Studio
# Chutzpah Test files
# Visual C++ cache files
# Visual Studio profiler
# Visual Studio Trace Files
# TFS 2012 Local Workspace
# Guidance Automation Toolkit
# ReSharper is a .NET coding add-in
# TeamCity is a build add-in
# DotCover is a Code Coverage Tool
# AxoCover is a Code Coverage Tool
# Coverlet is a free, cross platform Code Coverage Tool
coverage*[.json, .xml, .info]
# Visual Studio code coverage results
# NCrunch
# MightyMoose
# Web workbench (sass)
# Installshield output folder
# DocProject is a documentation generator add-in
# Click-Once directory
# Publish Web Output
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
# NuGet Packages
# NuGet Symbol Packages
# The packages folder can be ignored because of Package Restore
# except build/, which is used as an MSBuild target.
# Uncomment if necessary however generally it will be regenerated when needed
# NuGet v3's project.json files produces more ignorable files
# Microsoft Azure Build Output
# Microsoft Azure Emulator
# Windows Store app package directories and files
# Visual Studio cache files
# files ending in .cache can be ignored
# but keep track of directories ending in .cache
# Others
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
# RIA/Silverlight projects
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
# SQL Server files
# Business Intelligence projects
# Microsoft Fakes
# GhostDoc plugin setting file
# Node.js Tools for Visual Studio
# Visual Studio 6 build log
# Visual Studio 6 workspace options file
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
# Visual Studio LightSwitch build output
# Paket dependency manager
# FAKE - F# Make
# CodeRush personal settings
# Python Tools for Visual Studio (PTVS)
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
# Telerik's JustMock configuration file
# BizTalk build output
# OpenCover UI analysis results
# Azure Stream Analytics local run output
# MSBuild Binary and Structured Log
# NVidia Nsight GPU debugger configuration file
# MFractors (Xamarin productivity tool) working folder
# Local History for Visual Studio
# BeatPulse healthcheck temp database
# Backup folder for Package Reference Convert tool in Visual Studio 2017
# Ionide (cross platform F# VS Code tools) working folder

+ 22
- 82
README.md View File

@ -6,27 +6,27 @@ 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/Joe/amecs/releases/latest) and selecting `amecs.zip` from the **Downloads** section. Once downloaded, simply extract `amecs.zip` and 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`.
Alternatively, you could clone the repository:
## Summary
git clone https://git.ameliorated.info/Joe/amecs.git
As part of the amelioration process, certain UI elements, such as the **Region and language** page in Windows Settings, have been removed, and require alternative ways to execute the tasks. This script fills in those gaps, and allows for automating a large variety of customization tasks.
Once cloned, simply run `amecs.cmd`.
If you prefer manually executing commands for some of these tasks without a script, you can go through the step-by-step guides on [AME Guides](https://t.me/AMEGuides).
## Primary Functions
There are many actions in AME that require commands, the following functions essentially work as an interactive user interface for those.
There are many actions in AME that require commands or are otherwise unavailable. The following functions work as replacements for those actions.
#### Username/Password
This function allows for changing the user's username or password.
At its core, the following command is used for changing the username:
The following command can also be used for changing a username:
wmic useraccount where "name='<User's Username>'" rename '<New Username>'
Similarly, the following command is used for changing the password:
Similarly, the following command can be for changing the password:
net user "<User's Username>" "<New Password>"
@ -36,21 +36,17 @@ This function allows for changing the lockscreen image.
It works by taking ownership of the existing profile image files, and replacing them with the new image supplied by the user.
This is a modified version of [LoganDark's lockscreen-img script](https://git.ameliorated.info/LoganDark/lockscreen-img).
#### Profile Image
This function allows for changing the user's profile image (PFP).
It does this by taking ownership of the existing profile image files, and replacing them with the new image supplied by the user. Several necessary registry changes are made as well.
This is a modified version of [LoganDark's profile-img script](https://git.ameliorated.info/LoganDark/profile-img).
#### User Elevation
This function allows for elevating or de-elevating the user to or from administrator. Elevating the user disables the password requirement when trying to run an executable as administrator. However, this has large security implications, thus why it is not the default setting.
At its core, it uses the following command:
The following command can also be used for this purpose:
net localgroup administrators "<User's Username>" /add
@ -58,26 +54,6 @@ Or the following for de-elevating the user:
net localgroup administrators "<User's Username>" /delete
#### Display Language
This function allows for changing the user's display language.
Firstly, it prompts the user to download a portion of a \~5.5GB language pack ISO file. Unfortunately, Microsoft no longer publicly distributes individual language pack files, so this is necessary.
Once the ISO is downloaded, it extracts the ISO file, and installs the language pack for the selected display language using the following commands:
7z e -y -o"<Script Path>\LangPacks" "<User's Desktop>\LangPacks.ISO" x64\langpacks\*.cab
lpksetup /i <Language/region ID> /p "<User's Desktop>\LangPacks\Microsoft-Windows-Client-Language-Pack_x64_<Language/region ID>.cab"
After the language pack is installed, the display language can finally be set. At its core, this is done by using the following commands:
PowerShell -NoP -C "Set-WinSystemLocale <Language/region ID>"
PowerShell -NoP -C "Set-WinUserLanguageList <Language/region ID>"
The Language/region ID for a given language can be found [here](https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/available-language-packs-for-windows?view=windows-11#language-packs).
The script heavily enchances these simple commands. For instance, it keeps the existing keyboard input method (language), and let's the user decide whether or not to make the new language the default keyboard input method.
#### Keyboard Language
These functions allow for adding or removing a keyboard language.
@ -98,7 +74,7 @@ To remove a keyboard language, it fetches the existing language list, filters ou
This function allows for disabling or enabling the username login requirement.
At its core, it uses the following command:
The following command can also be used for this purpose:
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v dontdisplaylastusername /f
@ -110,9 +86,11 @@ Or the following for enabling the requirement:
This function allows for enabling or disabling the automatic login of the current user.
It does this by extracting an `AutoLogon.exe` file embedded within the script, and subsequently using it to enable AutoLogon.
It uses modified code from [rzander's AutoLogon program](https://github.com/rzander/AutoLogon), which can also be used for enabling AutoLogon.
The mentioned `AutoLogon.exe` program is a modified version of [rzander's AutoLogon program](https://github.com/rzander/AutoLogon).
#### .NET 3.5
This function allows for enabling or disabling .NET 3.5, requiring a Windows ISO or boot drive for installation.
## Extra Functions
@ -120,39 +98,7 @@ This section contains beta, legacy, or less used functions. Legacy functions are
#### Windows Subsystem for Linux (WSL)
These functions allow for various WSL related actions.
##### Enable/Disable WSL
This function allows for enabling or disabling WSL functionality.
At its core, this is done by using the following command:
DISM /Online /Enable-Feature /FeatureName:Microsoft-Windows-Subsystem-Linux -NoRestart
Or the following for disabling the requirement:
DISM /Online /Disable-Feature /FeatureName:Microsoft-Windows-Subsystem-Linux -NoRestart
##### Install WSL Distro
This function allows for installing a WSL distribution.
Firstly, it fetches the distro download link from this git repository (`links.txt`), and downloads the distro from said link\*. Once the distro is downloaded, the script extracts and places the distro in `<User's Local AppData Folder>\AME-WSL`, and subsequently installs the distro by running the distro's `.exe` file contained within.
After the distro has been installed, the script sends several commands to the distro that apply the username and password(s) supplied by the user.
\*If the distro link includes apps.microsoft.com, [store.rg-adguard.net](https://store.rg-adguard.net/) is used to fetch the download link.
##### Remove WSL Distro
This function allows for removing a WSL distribution.
At its core, it does this by unregistering the distro using the following command:
WSL --unregister <WSL Distro>
And subsequently removing the distro's installation files located in `<User's Local AppData Folder>\AME-WSL`.
These functions are currently unavailable.
#### Hibernation
@ -170,7 +116,7 @@ Or the following for disabling hibernation:
This function allows for enabling or disabling the Notification Center in the bottom right of the taskbar.
At its core, it uses the following command:
The following command can also be used for this purpose:
reg add "HKU\<User's SID>\Software\Policies\Microsoft\Windows\Explorer" /v DisableNotificationCenter /t REG_DWORD /d 0 /f
@ -182,7 +128,7 @@ Or the following for disabling the Notification Center:
This function allows for enabling or disabling desktop toast notifications.
At its core, it uses the following command:
The following command can also be used for this purpose:
reg add "HKU\<User's SID>\SOFTWARE\Microsoft\Windows\CurrentVersion\PushNotifications" /v ToastEnabled /t REG_DWORD /d 1 /f
@ -194,7 +140,7 @@ Or the following for disabling desktop notifications:
This function allows for enabling or disabling Windows Script Host (WSH). WSH is necessary for some programs.
At its core, the following commands are used:
The following command can also be used for this purpose:
reg add "HKU\<User's SID>\SOFTWARE\Microsoft\Windows Script Host\Settings" /v Enabled /t REG_DWORD /d 1 /f
reg add "HKLM\SOFTWARE\Microsoft\Windows Script Host\Settings" /v Enabled /t REG_DWORD /d 1 /f
@ -208,7 +154,7 @@ Or the following for disabling WSH:
This function allows for enabling or disabling Visual Basic Script (VBS). VBS is necessary for some programs.
At its core, the following command is used:
The following command can also be used for this purpose:
assoc .vbs=VBSFile
@ -220,7 +166,7 @@ Or the following for disabling VBS:
This function allows for enabling or disabling NCSI Active Probing. Some applications require this to be enabled.
At its core, it uses the following command:
The following command can also be used for this purpose:
reg add "HKLM\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet" /v EnableActiveProbing /t REG_DWORD /d 1 /f
@ -228,12 +174,6 @@ Or the following for disabling NCSI Active Probing:
reg add "HKLM\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet" /v EnableActiveProbing /t REG_DWORD /d 0 /f
#### New User
This function allows for creating partially functional and pre-configured users in Windows AME.
To do this, it uses a standard user creation command, followed by many registry edits to make the new user usable.
#### NVIDIA Control Panel
This function allows for installing or uninstalling NVIDIA Control Panel. This is useful since NVIDIA Control Panel no longer properly installs during a driver installation* due to it using an APPX deployment (Not supported in AME).
@ -242,10 +182,10 @@ Firstly, it fetches the store link from this git repository (`links.txt`), and f
For removal, it simply removes the `<System Drive>\Program Files\NVIDIA Control Panel` directory, as well as the start menu shortcut.
Note: Even though NVIDIA Control Panel installation failes during a driver installation, it still creates the necessary NVIDIA Control Panel files in `<System Drive>\Program Files\WindowsApps`. If this is the case, the script will attempt to use those files instead of downloading them.
Note: Even though NVIDIA Control Panel installation fails during a driver installation, it still creates the necessary NVIDIA Control Panel files in `<System Drive>\Program Files\WindowsApps`. If this is the case, the script will attempt to use those files instead of downloading them.
\*Standard drivers do not have this issue, however those have been discontinued by NVIDIA.
\*Standard drivers do not have this issue, however, those have been discontinued by NVIDIA.
## Known Issues
Some keyboard languages may not work, and a few are improperly tagged.
Some keyboard languages may not work, and a few may be improperly tagged.

+ 0
- 3948
amecs.cmd
File diff suppressed because it is too large
View File


BIN
screenshot.png View File

Before After
Width: 732  |  Height: 590  |  Size: 30 KiB Width: 732  |  Height: 538  |  Size: 34 KiB

BIN
src/7z.dll View File


+ 132
- 0
src/Actions/.NET.cs View File

@ -0,0 +1,132 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
using System.Threading;
using amecs.Misc;
using Ameliorated.ConsoleUtils;
using Microsoft.Dism;
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()
{
(_mountedPath, _isoPath, _, _, _) = SelectWindowsImage.GetMediaPath(true);
if (_mountedPath == null) return false;
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;
}
ConsoleTUI.OpenFrame.WriteCentered("\r\nInstalling .NET 3.5");
var topCache = Console.CursorTop;
var leftCache = Console.CursorLeft;
Console.WriteLine();
var inProgress = false;
try
{
using var indicator = new ConsoleUtils.LoadingIndicator();
DismApi.Initialize(DismLogLevel.LogErrors);
using (var session = DismApi.OpenOnlineSession())
{
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)
{
inProgress = true;
if (!indicatorStopped)
{
indicator.Stop();
Console.SetCursorPosition(leftCache, topCache);
Console.WriteLine(" ");
}
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);
}
DismApi.Shutdown();
Unmount();
} catch (Exception e)
{
while (inProgress)
{
Thread.Sleep(50);
}
Unmount();
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;
}
Console.WriteLine();
Console.WriteLine();
ConsoleTUI.OpenFrame.Close(".NET 3.5 installed successfully", ConsoleColor.Green, Console.BackgroundColor, new ChoicePrompt()
{
AnyKey = true,
Text = "Press any key to return to the Menu: "
});
return true;
}
[StructLayout(LayoutKind.Sequential)]
public struct COORD
{
public short X;
public short Y;
public COORD(short X, short Y)
{
this.X = X;
this.Y = Y;
}
};
[DllImport("kernel32.dll", SetLastError = true)]
internal static extern bool WriteConsoleOutputCharacter(IntPtr hConsoleOutput, StringBuilder lpCharacter, uint nLength, Languages.COORD dwWriteCoord, out uint lpNumberOfCharsWritten);
[DllImport("kernel32.dll", SetLastError = true)]
static extern IntPtr GetStdHandle(int nStdHandle);
}
}

+ 313
- 0
src/Actions/AutoLogon.cs View File

@ -0,0 +1,313 @@
using System;
using System.DirectoryServices.AccountManagement;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using Ameliorated.ConsoleUtils;
namespace amecs.Actions
{
public class AutoLogon
{
internal static class SafeNativeMethods
{
#region Structures
[StructLayout(LayoutKind.Sequential)]
public struct LSA_UNICODE_STRING : IDisposable
{
public UInt16 Length;
public UInt16 MaximumLength;
public IntPtr Buffer;
public void Dispose()
{
this = new LSA_UNICODE_STRING();
}
}
public struct LSA_OBJECT_ATTRIBUTES
{
public int Length;
public IntPtr RootDirectory;
public LSA_UNICODE_STRING ObjectName;
public UInt32 Attributes;
public IntPtr SecurityDescriptor;
public IntPtr SecurityQualityOfService;
}
public enum LSA_AccessPolicy : long
{
POLICY_VIEW_LOCAL_INFORMATION = 0x00000001L,
POLICY_VIEW_AUDIT_INFORMATION = 0x00000002L,
POLICY_GET_PRIVATE_INFORMATION = 0x00000004L,
POLICY_TRUST_ADMIN = 0x00000008L,
POLICY_CREATE_ACCOUNT = 0x00000010L,
POLICY_CREATE_SECRET = 0x00000020L,
POLICY_CREATE_PRIVILEGE = 0x00000040L,
POLICY_SET_DEFAULT_QUOTA_LIMITS = 0x00000080L,
POLICY_SET_AUDIT_REQUIREMENTS = 0x00000100L,
POLICY_AUDIT_LOG_ADMIN = 0x00000200L,
POLICY_SERVER_ADMIN = 0x00000400L,
POLICY_LOOKUP_NAMES = 0x00000800L,
POLICY_NOTIFICATION = 0x00001000L
}
#endregion
#region DLL Imports
[DllImport("advapi32")]
public static extern IntPtr FreeSid(IntPtr pSid);
[DllImport("advapi32.dll", PreserveSig = true)]
public static extern UInt32 LsaOpenPolicy(
ref LSA_UNICODE_STRING SystemName,
ref LSA_OBJECT_ATTRIBUTES ObjectAttributes,
Int32 DesiredAccess,
out IntPtr PolicyHandle);
[DllImport("advapi32.dll", SetLastError = true, PreserveSig = true)]
public static extern uint LsaStorePrivateData(
IntPtr PolicyHandle,
LSA_UNICODE_STRING[] KeyName,
LSA_UNICODE_STRING[] PrivateData);
[DllImport("advapi32.dll", PreserveSig = true)]
public static extern uint LsaRetrievePrivateData(
IntPtr PolicyHandle,
LSA_UNICODE_STRING[] KeyName,
out IntPtr PrivateData);
[DllImport("advapi32.dll", PreserveSig = true)]
public static extern uint LsaNtStatusToWinError(uint status);
[DllImport("advapi32.dll")]
public static extern uint LsaClose(IntPtr ObjectHandle);
#endregion
}
#region Functions
/// <summary>
/// Store Encrypted Data
/// </summary>
/// <param name="keyName"></param>
/// <param name="Data"></param>
/// <returns></returns>
public static long StoreData(String keyName, String Data)
{
long winErrorCode = 0;
IntPtr sid = IntPtr.Zero;
int sidSize = 0;
//allocate buffers
sid = Marshal.AllocHGlobal(sidSize);
//initialize an empty unicode-string
SafeNativeMethods.LSA_UNICODE_STRING systemName = new SafeNativeMethods.LSA_UNICODE_STRING();
//Set desired access rights (requested rights)
int access = (int)(SafeNativeMethods.LSA_AccessPolicy.POLICY_CREATE_SECRET);
//initialize a pointer for the policy handle
IntPtr policyHandle = IntPtr.Zero;
//these attributes are not used, but LsaOpenPolicy wants them to exists
SafeNativeMethods.LSA_OBJECT_ATTRIBUTES ObjectAttributes = new SafeNativeMethods.LSA_OBJECT_ATTRIBUTES();
ObjectAttributes.Length = 0;
ObjectAttributes.RootDirectory = IntPtr.Zero;
ObjectAttributes.Attributes = 0;
ObjectAttributes.SecurityDescriptor = IntPtr.Zero;
ObjectAttributes.SecurityQualityOfService = IntPtr.Zero;
//get a policy handle
uint resultPolicy = SafeNativeMethods.LsaOpenPolicy(ref systemName, ref ObjectAttributes, access, out policyHandle);
winErrorCode = SafeNativeMethods.LsaNtStatusToWinError(resultPolicy);
if (winErrorCode != 0)
{
ConsoleTUI.OpenFrame.WriteCenteredLine("OpenPolicy failed: " + winErrorCode);
}
else
{
//initialize an unicode-string for the keyName
SafeNativeMethods.LSA_UNICODE_STRING[] uKeyName = new SafeNativeMethods.LSA_UNICODE_STRING[1];
uKeyName[0] = new SafeNativeMethods.LSA_UNICODE_STRING();
uKeyName[0].Buffer = Marshal.StringToHGlobalUni(keyName);
uKeyName[0].Length = (UInt16)(keyName.Length * UnicodeEncoding.CharSize);
uKeyName[0].MaximumLength = (UInt16)((keyName.Length + 1) * UnicodeEncoding.CharSize);
//initialize an unicode-string for the Data to encrypt
SafeNativeMethods.LSA_UNICODE_STRING[] uData = new SafeNativeMethods.LSA_UNICODE_STRING[1];
uData[0] = new SafeNativeMethods.LSA_UNICODE_STRING();
uData[0].Buffer = Marshal.StringToHGlobalUni(Data);
uData[0].Length = (UInt16)(Data.Length * UnicodeEncoding.CharSize);
uData[0].MaximumLength = (UInt16)((Data.Length + 1) * UnicodeEncoding.CharSize);
//Store Encrypted Data:
SafeNativeMethods.LsaStorePrivateData(policyHandle, uKeyName, uData);
//winErrorCode = LsaNtStatusToWinError(res);
if (winErrorCode != 0)
{
ConsoleTUI.OpenFrame.WriteCenteredLine("LsaStorePrivateData failed: " + winErrorCode);
}
SafeNativeMethods.LsaClose(policyHandle);
}
SafeNativeMethods.FreeSid(sid);
return winErrorCode;
}
/// <summary>
/// Retrieve Encrypted Data
/// </summary>
/// <param name="keyName"></param>
/// <returns></returns>
public static string RetrieveData(String keyName)
{
string sout = "";
long winErrorCode = 0;
IntPtr sid = IntPtr.Zero;
int sidSize = 0;
//allocate buffers
sid = Marshal.AllocHGlobal(sidSize);
//initialize an empty unicode-string
SafeNativeMethods.LSA_UNICODE_STRING systemName = new SafeNativeMethods.LSA_UNICODE_STRING();
//Set desired access rights (requested rights)
int access = (int)(SafeNativeMethods.LSA_AccessPolicy.POLICY_CREATE_SECRET);
//initialize a pointer for the policy handle
IntPtr policyHandle = IntPtr.Zero;
//these attributes are not used, but LsaOpenPolicy wants them to exists
SafeNativeMethods.LSA_OBJECT_ATTRIBUTES ObjectAttributes = new SafeNativeMethods.LSA_OBJECT_ATTRIBUTES();
ObjectAttributes.Length = 0;
ObjectAttributes.RootDirectory = IntPtr.Zero;
ObjectAttributes.Attributes = 0;
ObjectAttributes.SecurityDescriptor = IntPtr.Zero;
ObjectAttributes.SecurityQualityOfService = IntPtr.Zero;
//get a policy handle
uint resultPolicy = SafeNativeMethods.LsaOpenPolicy(ref systemName, ref ObjectAttributes, access, out policyHandle);
winErrorCode = SafeNativeMethods.LsaNtStatusToWinError(resultPolicy);
if (winErrorCode != 0)
{
ConsoleTUI.OpenFrame.WriteCenteredLine("OpenPolicy failed: " + winErrorCode);
}
else
{
//initialize an unicode-string for the keyName
SafeNativeMethods.LSA_UNICODE_STRING[] uKeyName = new SafeNativeMethods.LSA_UNICODE_STRING[1];
uKeyName[0] = new SafeNativeMethods.LSA_UNICODE_STRING();
uKeyName[0].Buffer = Marshal.StringToHGlobalUni(keyName);
uKeyName[0].Length = (UInt16)(keyName.Length * UnicodeEncoding.CharSize);
uKeyName[0].MaximumLength = (UInt16)((keyName.Length + 1) * UnicodeEncoding.CharSize);
//Store Encrypted Data:
IntPtr pData;
long result = SafeNativeMethods.LsaRetrievePrivateData(policyHandle, uKeyName, out pData);
//winErrorCode = LsaNtStatusToWinError(res);
if (winErrorCode != 0)
{
ConsoleTUI.OpenFrame.WriteCenteredLine("LsaStorePrivateData failed: " + winErrorCode);
}
SafeNativeMethods.LSA_UNICODE_STRING ss = (SafeNativeMethods.LSA_UNICODE_STRING)Marshal.PtrToStructure(pData, typeof(SafeNativeMethods.LSA_UNICODE_STRING));
sout = Marshal.PtrToStringAuto(ss.Buffer);
SafeNativeMethods.LsaClose(policyHandle);
}
SafeNativeMethods.FreeSid(sid);
return sout;
}
#endregion
private const string LogonKey = @"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon";
public static bool Disable() => amecs.RunBasicAction("Disabling AutoLogon", "AutoLogon disabled successfully", new Action(() =>
{
new Reg.Value() { KeyName = LogonKey, ValueName = "DefaultUserName", Data = "", Type = Reg.RegistryValueType.REG_SZ}.Apply();
new Reg.Value() { KeyName = LogonKey, ValueName = "AutoAdminLogon", Operation = Reg.RegistryValueOperation.Delete}.Apply();
new Reg.Value() { KeyName = LogonKey, ValueName = "AutoLogonCount", Operation = Reg.RegistryValueOperation.Delete}.Apply();
new Reg.Value() { KeyName = LogonKey, ValueName = "ForceAutoLogon", Operation = Reg.RegistryValueOperation.Delete}.Apply();
new Reg.Value() { KeyName = LogonKey, ValueName = "DisableCAD", Operation = Reg.RegistryValueOperation.Delete}.Apply();
new Reg.Value() { KeyName = LogonKey, ValueName = "DefaultPassword", Operation = Reg.RegistryValueOperation.Delete}.Apply();
StoreData("DefaultPassword", "");
Thread.Sleep(1700);
}));
public static bool Enable()
{
PrincipalContext context = new PrincipalContext(ContextType.Machine);
string password = "";
while (true)
{
password = new InputPrompt() { MaskInput = true, Text = "Enter your password, or press escape to quit: " }.Start();
if (password == null)
return true;
if (String.IsNullOrEmpty(password))
{
try
{
Globals.User.ChangePassword("", "");
break;
} catch {}
}
else if (context.ValidateCredentials(Globals.Username, password))
break;
ConsoleTUI.OpenFrame.WriteLine("Incorrect password.");
Console.WriteLine();
}
try
{
ConsoleTUI.OpenFrame.WriteCentered("\r\nEnabling AutoLogon");
using (new ConsoleUtils.LoadingIndicator(true))
{
new Reg.Value() { KeyName = LogonKey, ValueName = "DefaultUserName", Data = Globals.Username, Type = Reg.RegistryValueType.REG_SZ}.Apply();
new Reg.Value() { KeyName = LogonKey, ValueName = "DefaultDomainName", Data = Environment.MachineName, Type = Reg.RegistryValueType.REG_SZ}.Apply();
new Reg.Value() { KeyName = LogonKey, ValueName = "AutoAdminLogon", Data = 1, Type = Reg.RegistryValueType.REG_DWORD}.Apply();
new Reg.Value() { KeyName = LogonKey, ValueName = "AutoLogonCount", Operation = Reg.RegistryValueOperation.Delete}.Apply();
new Reg.Value() { KeyName = LogonKey, ValueName = "DisableCAD", Data = 1, Type = Reg.RegistryValueType.REG_DWORD}.Apply();
new Reg.Value() { KeyName = LogonKey, ValueName = "DefaultPassword", Operation = Reg.RegistryValueOperation.Delete}.Apply();
StoreData("DefaultPassword", password);
Thread.Sleep(1700);
}
} catch (Exception e)
{
Console.WriteLine();
ConsoleTUI.OpenFrame.Close("Error: " + e.Message.TrimEnd('\n').TrimEnd('\r'), ConsoleColor.Red, Console.BackgroundColor, new ChoicePrompt()
{
AnyKey = true,
Text = "Press any key to return to the Menu: "
});
return false;
}
Console.WriteLine();
ConsoleTUI.OpenFrame.Close($"AutoLogon enabled successfully", ConsoleColor.Green, Console.BackgroundColor, new ChoicePrompt()
{
AnyKey = true,
Text = "Press any key to return to the Menu: "
});
return true;
}
}
}

+ 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;
}
}
}

+ 21
- 0
src/Actions/Elevation.cs View File

@ -0,0 +1,21 @@
using System;
using System.Threading;
namespace amecs.Actions
{
public class Elevation
{
public static bool Elevate() => amecs.RunBasicAction("Elevating user to Administrator", "The current user is now an Administrator", new Action(() =>
{
Globals.Administrators.Members.Add(Globals.User);
Globals.Administrators.Save();
Thread.Sleep(1000);
}), true);
public static bool DeElevate() => amecs.RunBasicAction("Revoking Admin rights from the current user", "Admin rights have been revoked for the current user", new Action(() =>
{
Globals.Administrators.Members.Remove(Globals.User);
Globals.Administrators.Save();
Thread.Sleep(1000);
}), true);
}
}

+ 1089
- 0
src/Actions/Languages.cs
File diff suppressed because it is too large
View File


+ 113
- 0
src/Actions/Lockscreen.cs View File

@ -0,0 +1,113 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Security;
using System.Threading;
using Ameliorated.ConsoleUtils;
using Microsoft.Win32;
using System.Windows.Forms;
namespace amecs.Actions
{
public class Lockscreen
{
public static bool ChangeImage()
{
ConsoleTUI.OpenFrame.WriteCenteredLine("Select an image");
Thread.Sleep(1000);
var dialog = new System.Windows.Forms.OpenFileDialog();
dialog.Filter = "Image Files (*.jpg; *.jpeg; *.png; *.bmp; *.jfif)| *.jpg; *.jpeg; *.png; *.bmp; *.jfif"; // 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)
{
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();
var choice = new ChoicePrompt() { Text = "Remove lockscreen blur? (Y/N): " }.Start();
if (!choice.HasValue) return true;
bool blur = choice == 0;
ConsoleTUI.OpenFrame.WriteCentered("\r\nSetting lockscreen image");
using (new ConsoleUtils.LoadingIndicator(true))
{
Thread.Sleep(500);
try
{
if (blur)
new Reg.Value()
{
KeyName = @"HKLM\SOFTWARE\Policies\Microsoft\Windows\System",
ValueName = "DisableAcrylicBackgroundOnLogon",
Type = Reg.RegistryValueType.REG_DWORD,
Data = 1,
}.Apply();
else
new Reg.Value()
{
KeyName = @"HKLM\SOFTWARE\Policies\Microsoft\Windows\System",
ValueName = "DisableAcrylicBackgroundOnLogon",
Type = Reg.RegistryValueType.REG_DWORD,
Data = 0,
}.Apply();
} catch { }
new Reg.Value()
{
KeyName = @"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Creative\" + Globals.UserSID,
ValueName = "RotatingLockScreenEnabled",
Type = Reg.RegistryValueType.REG_DWORD,
Data = 0,
}.Apply();
new Reg.Value()
{
KeyName = @$"HKU\{Globals.UserSID}\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager",
ValueName = "RotatingLockScreenEnabled",
Type = Reg.RegistryValueType.REG_DWORD,
Data = 0,
}.Apply();
File.Delete(Environment.ExpandEnvironmentVariables(@"%WINDIR%\Web\Screen\img100.jpg"));
File.Copy(file, Environment.ExpandEnvironmentVariables(@"%WINDIR%\Web\Screen\img100.jpg"));
foreach (var dataDir in Directory.EnumerateDirectories(Environment.ExpandEnvironmentVariables(@"%PROGRAMDATA%\Microsoft\Windows\SystemData")))
{
var subDir = Path.Combine(dataDir, "ReadOnly");
if (!Directory.Exists(subDir))
continue;
Directory.GetDirectories(subDir, "Lockscreen_*").ToList().ForEach(x => Directory.Delete(x, true));
}
}
Console.WriteLine();
ConsoleTUI.OpenFrame.Close("Lockscreen image changed successfully", ConsoleColor.Green, Console.BackgroundColor, new ChoicePrompt() {AnyKey = true, Text = "Press any key to return to the Menu: "});
return true;
}
else
{
Console.WriteLine();
ConsoleTUI.OpenFrame.Close("You must select an image.", new ChoicePrompt() {AnyKey = true, Text = "Press any key to return to the Menu: "});
return true;
}
}
}
}

+ 124
- 0
src/Actions/Profile.cs View File

@ -0,0 +1,124 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Security;
using System.Threading;
using System.Windows.Forms;
using Ameliorated.ConsoleUtils;
using System.Drawing;
using System.Security.AccessControl;
using System.Security.Principal;
namespace amecs.Actions
{
public class Profile
{
public static bool ChangeImage()
{
ConsoleTUI.OpenFrame.WriteCenteredLine("Select an image");
Thread.Sleep(1000);
var dialog = new System.Windows.Forms.OpenFileDialog();
dialog.Filter = "Image Files (*.jpg; *.jpeg; *.png; *.bmp; *.jfif)| *.jpg; *.jpeg; *.png; *.bmp; *.jfif"; // 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)
{
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;
}
ConsoleTUI.OpenFrame.WriteCentered("\r\nSetting profile image");
using (new ConsoleUtils.LoadingIndicator(true))
{
var pfpDir = Path.Combine(Environment.ExpandEnvironmentVariables("%PUBLIC%\\AccountPictures"), Globals.UserSID);
if (Directory.Exists(pfpDir))
{
try
{
Directory.Delete(pfpDir, true);
} catch (Exception e)
{
var logdi = new DirectoryInfo(pfpDir) { Attributes = FileAttributes.Normal };
try
{
NSudo.GetOwnershipPrivilege();
var logdirsec = logdi.GetAccessControl();
logdirsec.SetOwner(WindowsIdentity.GetCurrent().User);
logdi.SetAccessControl(logdirsec);
logdirsec = new DirectorySecurity();
logdirsec.AddAccessRule(new FileSystemAccessRule(WindowsIdentity.GetCurrent().User, FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.NoPropagateInherit, AccessControlType.Allow));