Skip to content

Commit

Permalink
feat: replace msgboxes with Read-MessageBox
Browse files Browse the repository at this point in the history
  • Loading branch information
he3als committed Aug 10, 2024
1 parent 1e8bc61 commit 91e0b64
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ $items = @{
$sendTo = Get-ChildItem ([Environment]::GetFolderPath('SendTo')) -Force
$sys32 = [Environment]::GetFolderPath('System')
$shell = New-Object -Com WScript.Shell
$windir = [Environment]::GetFolderPath('Windows')
$env:PSModulePath += ";$windir\AtlasModules\Scripts\Modules"

# Get Bluetooth path
foreach ($lnk in (($sendTo | Where-Object { $_.Extension -eq ".lnk" }).FullName)) {
Expand Down Expand Up @@ -103,12 +105,6 @@ foreach ($item in $items.GetEnumerator()) {
}

# Restart Explorer prompt
Add-Type -AssemblyName System.Windows.Forms
if (([System.Windows.Forms.MessageBox]::Show(
"Would you like to restart Windows Explorer now? This will finalise the changes.",
"Atlas - Send To Debloat",
[System.Windows.Forms.MessageBoxButtons]::YesNo,
[System.Windows.Forms.MessageBoxIcon]::Information
)) -eq [System.Windows.Forms.DialogResult]::Yes) {
if ((Read-MessageBox -Title "Atlas - Send To Debloat" -Body 'Would you like to restart Windows Explorer now? This will finalise the changes' -Icon Information) -eq 'Yes') {
Stop-Process -Name explorer -Force
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
& "$([Environment]::GetFolderPath('Windows'))\AtlasModules\Scripts\wingetCheck.cmd"
$windir = [Environment]::GetFolderPath('Windows')
$env:PSModulePath += ";$windir\AtlasModules\Scripts\Modules"
& "$windir\AtlasModules\Scripts\wingetCheck.cmd"
if ($LASTEXITCODE -ne 0) { exit 1 }

Clear-Host
Expand Down Expand Up @@ -261,7 +263,7 @@ $InstallButton.Text = "Install"
$InstallButton.Add_Click({
$checkedBoxes = $Form.Controls | Where-Object { $_ -is [System.Windows.Forms.Checkbox] -and $_.Checked }
if ($checkedBoxes.Count -eq 0) {
[System.Windows.Forms.MessageBox]::Show("Please select at least one software package to install.", "No package selected", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Information)
Read-MessageBox -Title "No package selected" -Body 'Please select at least one software package to install' -Icon Information -Buttons Ok | Out-Null
}
else {
$global:install = $true
Expand Down
19 changes: 7 additions & 12 deletions src/playbook/Executables/AtlasModules/Scripts/packageInstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ if (!([Security.Principal.WindowsIdentity]::GetCurrent().User.Value -eq 'S-1-5-1
# ======================================================================================================================= #
$sys32 = [Environment]::GetFolderPath('System')
$windir = [Environment]::GetFolderPath('Windows')
$env:PSModulePath += ";$windir\AtlasModules\Scripts\Modules"
$safeModePackageList = "$sys32\safeModePackagesToInstall.atlasmodule"
$env:path = "$windir;$sys32;$sys32\Wbem;$sys32\WindowsPowerShell\v1.0;" + $env:path
$errorLevel = $warningLevel = 0
Expand Down Expand Up @@ -255,21 +256,15 @@ if ($SafeMode) {
}

if ($FailMessage) {
Add-Type -AssemblyName PresentationFramework
$body = "It appears that there was an issue while attempting to disable certain Windows components.
$body = @"
It appears that there was an issue while attempting to disable certain Windows components.
Would you like to restart your system into Safe Mode and try again? This process should not take much time.
Would you like Atlas to restart your system into Safe Mode and try again? This process shouldn't take much time.
Please note that if you chose to disable Windows Defender, it may still remain enabled if you select 'No'. However, you can always try disabling it later in the Atlas folder."

$result = [System.Windows.MessageBox]::Show(
$body,
"Atlas - Component Modification",
[System.Windows.MessageBoxButton]::YesNo,
[System.Windows.MessageBoxImage]::Question
)
Please note that if you chose to disable Windows Defender, it may still remain enabled if you select 'No'. However, you can always try disabling it later in the Atlas folder.
"@

if ($result -eq 'Yes') {
if ((Read-MessageBox -Title "Atlas - Component Modification" -Body $body -Icon Question) -eq 'Yes') {
SafeMode -Enable
Restart
}
Expand Down
8 changes: 4 additions & 4 deletions src/playbook/Executables/SOFTWARE.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ param (
[switch]$Firefox
)

$env:PSModulePath += ";$PWD\AtlasModules\Scripts\Modules"

# ----------------------------------------------------------------------------------------------------------- #
# Software is no longer installed with a package manager anymore to be as fast and as reliable as possible. #
# ----------------------------------------------------------------------------------------------------------- #
Expand Down Expand Up @@ -159,15 +161,13 @@ function InstallNanaZip {
if ($assets.Count -eq 2) {
$7zipRegistry = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip"
if (Test-Path $7zipRegistry) {
$WindowTitle = 'Installing NanaZip - Atlas'

$Message = @'
Would you like to uninstall 7-Zip and replace it with NanaZip?
NanaZip is a fork of 7-Zip with an updated user interface and extra features.
'@
if ((New-Object -ComObject "Wscript.Shell").Popup($Message,300,$WindowTitle,4+32+4096) -eq 6) {

if ((Read-MessageBox -Title 'Installing NanaZip - Atlas' -Body $Message -Icon Question) -eq 'Yes') {
$7zipUninstall = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" -Name "QuietUninstallString" -EA 0).QuietUninstallString
Write-Output "Uninstalling 7-Zip..."
Start-Process -FilePath "cmd" -WindowStyle Hidden -ArgumentList "/c $7zipUninstall" -Wait
Expand Down

0 comments on commit 91e0b64

Please sign in to comment.