21 Commits
v1.1 ... master

Author SHA1 Message Date
  he3als e986cde90b
fix(.net 3.5): final touches (ejecting ISO, etc) 3 months ago
  he3als 96135bca0d
fix(.net 3.5): general fixes 3 months ago
  he3als e0d0bfd030
feat: .NET 3.5 with USB/folder 3 months ago
  he3als 8c6c9c3d3c
feat(users): password reconfirmation 3 months ago
  Styris d1858244ba Update README 6 months ago
  Styris 14359b9855 C# Update 7 months ago
  Styris 8fb460ba4f Update 'README.md' 1 year ago
  Styris bc8cec4dab Update 'README.md' 1 year ago
  Styris 8b04e77b8f Update 'README.md' 1 year ago
  Styris d5778d8e47 Update 'README.md' 1 year ago
  Styris 8688290afd Update README 1 year ago
  Styris 6ed9ff89f6 Update README 1 year ago
  Styris 09cece9a2b Release v1.4 1 year ago
  Joe 1d8824361f Remove Usage note from README 1 year ago
  Joe fe6a69b0b9 Release v1.3 1 year ago
  Joe 261ffbfe3b Release v1.3 1 year ago
  Joe 132207db69 Update README 1 year ago
  Joe c77ddc8b92 Update README 1 year ago
  Joe e9826f2421 Update README 1 year ago
  Joe 7e25b9492e Update to v1.2 1 year ago
  Joe 8975759622 Update 'screenshot.png' 1 year ago
42 changed files with 8084 additions and 3889 deletions
Split View
  1. +559
    -0
      .gitignore
  2. +40
    -76
      README.md
  3. +0
    -3813
      amecs.cmd
  4. BIN
      screenshot.png
  5. BIN
      src/7z.dll
  6. +221
    -0
      src/Actions/.NET.cs
  7. +313
    -0
      src/Actions/AutoLogon.cs
  8. +21
    -0
      src/Actions/Elevation.cs
  9. +1089
    -0
      src/Actions/Languages.cs
  10. +113
    -0
      src/Actions/Lockscreen.cs
  11. +124
    -0
      src/Actions/Profile.cs
  12. +220
    -0
      src/Actions/UserPass.cs
  13. +19
    -0
      src/Actions/UsernameRequirement.cs
  14. +299
    -0
      src/Actions/Users.cs
  15. +201
    -0
      src/Ameliorated.ConsoleUtils/ConsoleTUI/ConsoleTUI.cs
  16. +198
    -0
      src/Ameliorated.ConsoleUtils/ConsoleTUI/Frame.cs
  17. +396
    -0
      src/Ameliorated.ConsoleUtils/ConsoleTUI/FrameWriteMethods.cs
  18. +433
    -0
      src/Ameliorated.ConsoleUtils/ConsoleTUI/Menu.cs
  19. +196
    -0
      src/Ameliorated.ConsoleUtils/ConsoleTUI/MouseInterface.cs
  20. +604
    -0
      src/Ameliorated.ConsoleUtils/ConsoleTUI/Prompt.cs
  21. +250
    -0
      src/Ameliorated.ConsoleUtils/ConsoleUtils.cs
  22. +88
    -0
      src/Ameliorated.ConsoleUtils/Extensions.cs
  23. +74
    -0
      src/Ameliorated.ConsoleUtils/ParentProcess.cs
  24. +6
    -0
      src/Ameliorated.ConsoleUtils/Payload.cs
  25. +342
    -0
      src/Extra/Extra.cs
  26. +281
    -0
      src/Extra/NVCP.cs
  27. +40
    -0
      src/Extra/WSH.cs
  28. +3
    -0
      src/FodyWeavers.xml
  29. +41
    -0
      src/Globals.cs
  30. +220
    -0
      src/Misc.FolderPicker/FolderPicker.cs
  31. +512
    -0
      src/NSudo.cs
  32. +168
    -0
      src/Program.cs
  33. +35
    -0
      src/Properties/AssemblyInfo.cs
  34. +375
    -0
      src/Registry.cs
  35. +263
    -0
      src/amecs.cs
  36. +252
    -0
      src/amecs.csproj
  37. BIN
      src/amecs.ico
  38. BIN
      src/amecs.png
  39. +16
    -0
      src/amecs.sln
  40. BIN
      src/amecs_old.ico
  41. +10
    -0
      src/app.manifest
  42. +62
    -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

+ 40
- 76
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,71 +98,63 @@ 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
These functions are currently unavailable.
Or the following for disabling the requirement:
#### Hibernation
DISM /Online /Disable-Feature /FeatureName:Microsoft-Windows-Subsystem-Linux -NoRestart
This function allows for enabling or disabling the hibernation option in Windows.
##### Install WSL Distro
At its core, the following commands are used:
This function allows for installing a WSL distribution.
powercfg /HIBERNATE /TYPE FULL
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.
Or the following for disabling hibernation:
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.
powercfg /HIBERNATE OFF
\*If the distro link includes apps.microsoft.com, [store.rg-adguard.net](https://store.rg-adguard.net/) is used to fetch the download link.
#### Notification Center
##### Remove WSL Distro
This function allows for enabling or disabling the Notification Center in the bottom right of the taskbar.
This function allows for removing a WSL distribution.
The following command can also be used for this purpose:
At its core, it does this by unregistering the distro using the following command:
reg add "HKU\<User's SID>\Software\Policies\Microsoft\Windows\Explorer" /v DisableNotificationCenter /t REG_DWORD /d 0 /f
WSL --unregister <WSL Distro>
Or the following for disabling the Notification Center:
And subsequently removing the distro's installation files located in `<User's Local AppData Folder>\AME-WSL`.
reg add "HKU\<User's SID>\Software\Policies\Microsoft\Windows\Explorer" /v DisableNotificationCenter /t REG_DWORD /d 1 /f
#### Hibernation
#### Desktop Notifications
This function allows for enabling or disabling the hibernation option in Windows.
This function allows for enabling or disabling desktop toast notifications.
At its core, the following commands are used:
The following command can also be used for this purpose:
powercfg /HIBERNATE /TYPE FULL
reg add "HKU\<User's SID>\SOFTWARE\Microsoft\Windows\CurrentVersion\PushNotifications" /v ToastEnabled /t REG_DWORD /d 1 /f
Or the following for disabling hibernation:
Or the following for disabling desktop notifications:
powercfg /HIBERNATE OFF
reg add "HKU\<User's SID>\SOFTWARE\Microsoft\Windows\CurrentVersion\PushNotifications" /v ToastEnabled /t REG_DWORD /d 0 /f
#### Windows Script Host (Legacy)
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 "HKEY_USERS\<User's SID>\SOFTWARE\Microsoft\Windows Script Host\Settings" /v Enabled /t REG_DWORD /d 1 /f
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
Or the following for disabling WSH:
reg add "HKEY_USERS\<User's SID>\SOFTWARE\Microsoft\Windows Script Host\Settings" /v Enabled /t REG_DWORD /d 0 /f
reg add "HKU\<User's SID>\SOFTWARE\Microsoft\Windows Script Host\Settings" /v Enabled /t REG_DWORD /d 0 /f
reg add "HKLM\SOFTWARE\Microsoft\Windows Script Host\Settings" /v Enabled /t REG_DWORD /d 0 /f
#### Visual Basic Script (Legacy)
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
@ -196,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
@ -204,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).
@ -218,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
- 3813
amecs.cmd
File diff suppressed because it is too large
View File


BIN
screenshot.png View File

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

BIN
src/7z.dll View File


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

@ -0,0 +1,221 @@
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 System.Windows.Forms;
using Misc.FolderPicker;
using Ameliorated.ConsoleUtils;
using Microsoft.Dism;
namespace amecs.Actions
{
public class _NET
{
private static string file;
private static bool CheckFileViolation(string inputFile)
{
try
{
file = inputFile;
}
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 true;
}
return false;
}
private static bool DismountImage()
{
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();
return true;
}
public static bool Install()
{
string letter;
var choice = new ChoicePrompt() { Text = "To install .NET 3.5, Windows installation media is needed.\r\nDo you have a Windows USB instead of an ISO? (Y/N): " }.Start();
if (choice == null) return false;
var usingFolder = choice == 0;
if (usingFolder)
{
var dlg = new FolderPicker();
dlg.InputPath = Globals.UserFolder;
if (!dlg.ShowDialog(IntPtr.Zero, false).GetValueOrDefault())
{
Console.WriteLine();
ConsoleTUI.OpenFrame.Close("\r\nYou must select a folder or drive.", new ChoicePrompt() {AnyKey = true, Text = "Press any key to return to the Menu: "});
return true;
}
if (CheckFileViolation(dlg.ResultPath)) return false;
letter = dlg.ResultPath;
}
else
{
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)
{
if (CheckFileViolation(dialog.FileName)) return false;
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 true;
}
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())
{
DismountImage();
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();
bool inProgress = false;
try
{
using (var indicator = new ConsoleUtils.LoadingIndicator())
{
DismApi.Initialize(DismLogLevel.LogErrors);
using (var session = DismApi.OpenOnlineSession())
{
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);
}
DismApi.Shutdown();
if (!usingFolder) DismountImage();
}
} catch (Exception e)
{
while (inProgress)
{
Thread.Sleep(50);
}
if (!usingFolder)
{
try
{
DismountImage();
}
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;
}
Console.WriteLine();
Console.WriteLine();
if (!usingFolder)
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;
}
}
}

+ 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));
logdi.SetAccessControl(logdirsec);
} catch (Exception exception)
{
}
foreach (var info in logdi.GetFileSystemInfos("*", SearchOption.AllDirectories))
{
info.Attributes = FileAttributes.Normal;
}
Directory.Delete(pfpDir, true);
}
}
Directory.CreateDirectory(pfpDir);
var image = Image.FromFile(file);
var pfpKey = @"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\AccountPicture\Users\" + Globals.UserSID;
new Reg.Key() { KeyName = pfpKey, Operation = RegistryOperation.Delete }.Apply();
foreach (var res in new [] { 32, 40, 48, 64, 96, 192, 208, 240, 424, 448, 1080 })
{
var bitmap = new Bitmap(res, res);
var graph = Graphics.FromImage(bitmap);
graph.DrawImage(image, 0, 0, res, res);
var saveLoc = Path.Combine(pfpDir, $"{res}x{res}.png");
bitmap.Save(saveLoc);
new Reg.Value() { KeyName = pfpKey, ValueName = "Image" + res, Type = Reg.RegistryValueType.REG_SZ, Data = saveLoc }.Apply();
}
new Reg.Value() { KeyName = pfpKey, ValueName = "UserPicturePath", Type = Reg.RegistryValueType.REG_SZ, Data = Path.Combine(pfpDir, $"448x448.png") }.Apply();
try
{
Process proc = new Process();
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.StartInfo.FileName = "gpupdate.exe";
proc.StartInfo.Arguments = "/force";
proc.Start();
proc.WaitForExit(20000);
} catch { }
}
Console.WriteLine();
ConsoleTUI.OpenFrame.Close("Profile 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;
}
}
}
}

+ 220
- 0
src/Actions/UserPass.cs View File

@ -0,0 +1,220 @@
using System;
using System.Collections.Generic;
using System.DirectoryServices;
using System.DirectoryServices.AccountManagement;
using Ameliorated.ConsoleUtils;
using System.Linq;
using System.Security;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
namespace amecs.Actions
{
public static class UserPass
{
public static bool ShowMenu()
{
var mainMenu = new Ameliorated.ConsoleUtils.Menu()
{
Choices =
{
new Menu.MenuItem("Change Username", new Func<bool>(ChangeUsername)),
new Menu.MenuItem("Change Password", new Func<bool>(ChangePassword)),
new Menu.MenuItem("Change Display Name", new Func<bool>(ChangeDisplayName)),
new Menu.MenuItem("Change Administrator Password", new Func<bool>(ChangeAdminPassword)),
Menu.MenuItem.Blank,
new Menu.MenuItem("Return to Menu", new Func<bool>(() => true)),
new Menu.MenuItem("Exit", new Func<bool>(Globals.Exit)),
},
SelectionForeground = ConsoleColor.Green
};
mainMenu.Write();
var result = (Func<bool>)mainMenu.Load();
return result.Invoke();
}
public static bool ChangeUsername()
{
try
{
while (true)
{
var username = new InputPrompt() { Text = "Enter new username, or press escape to quit: " }.Start();
if (username == null)
return true;
if (String.IsNullOrEmpty(username) || !Regex.Match(username, @"^\w[\w\.\- ]{0,19}$").Success)
{
ConsoleTUI.OpenFrame.WriteLine("Username is invalid.");
Console.WriteLine();
continue;
}
if (Globals.Username.Equals(username))
{
ConsoleTUI.OpenFrame.WriteLine("Username matches the current username.");
Console.WriteLine();
continue;
}
try
{
ConsoleTUI.OpenFrame.WriteCentered("\r\nSetting new username");
using (new ConsoleUtils.LoadingIndicator(true))
{
DirectoryEntry entry = (DirectoryEntry)Globals.User.GetUnderlyingObject();
entry.Rename(username);
entry.CommitChanges();
PrincipalContext context = new PrincipalContext(ContextType.Machine);
PrincipalSearcher userPrincipalSearcher = new PrincipalSearcher(new UserPrincipal(context));
Globals.User = userPrincipalSearcher.FindAll().FirstOrDefault(x => (x is UserPrincipal) && x.Sid.Value == Globals.UserSID) as UserPrincipal;
break;
}
} catch (System.Runtime.InteropServices.COMException e)
{
if (e.ErrorCode != -2147022694)
throw e;
ConsoleTUI.OpenFrame.WriteLine("Username is invalid.");
Console.WriteLine();
}
}
} catch (Exception e)
{
Console.WriteLine