Refactor show message box functions and rename file

- Update Remove and Disable Xbox messages
GUI: Added 3 new installations
General: Added ASCII text by running the script
main
Plínio Larrubia 3 years ago committed by Plínio Larrubia
parent d9f7fa5a3a
commit 97216ca9e7
No known key found for this signature in database
GPG Key ID: 057B0A87CB137C69

@ -40,22 +40,23 @@ function Use-Scripts() {
function Main() {
Request-PrivilegesElevation # Check admin rights
Request-PrivilegesElevation # Check admin rights
Write-Host "Your Current Folder $pwd"
Write-Host "Script Root Folder $PSScriptRoot"
Get-ChildItem -Recurse $PSScriptRoot\*.ps*1 | Unblock-File
Import-Module -DisableNameChecking "$PSScriptRoot\src\lib\set-console-style.psm1"
Set-ConsoleStyle # Makes the console look cooler
Set-ConsoleStyle # Makes the console look cooler
Import-Module -DisableNameChecking "$PSScriptRoot\src\lib\set-script-policy.psm1"
Import-Module -DisableNameChecking "$PSScriptRoot\src\lib\simple-message-box.psm1"
Import-Module -DisableNameChecking "$PSScriptRoot\src\lib\show-message-box.psm1"
Import-Module -DisableNameChecking "$PSScriptRoot\src\lib\title-templates.psm1"
Set-UnrestrictedPermissions # Unlock script usage
Use-Scripts # Run all scripts inside 'scripts' folder
Set-RestrictedPermissions # Lock script usage
Request-PcRestart # Prompt options to Restart the PC
Write-ASCIIScriptName # Thanks Figlet
Request-PcRestart # Prompt options to Restart the PC
}

@ -42,9 +42,9 @@ function Show-GUI() {
$Panel3 = Create-Panel -Width (($PWidth * 2) - 15) -Height $PHeight -LocationX ($PWidth * $CurrentPanelIndex) -LocationY 0 -HasVerticalScroll $true
# Panels to put Labels and Buttons
$Panel3_1 = Create-Panel -Width ($PWidth - 15) -Height ($PHeight * 2.9) -LocationX 0 -LocationY 0
$Panel3_1 = Create-Panel -Width ($PWidth - 15) -Height ($PHeight * 3.0) -LocationX 0 -LocationY 0
$Global:CurrentPanelIndex++
$Panel3_2 = Create-Panel -Width $PWidth -Height ($PHeight * 2.9) -LocationX ($PWidth - 15) -LocationY 0
$Panel3_2 = Create-Panel -Width $PWidth -Height ($PHeight * 3.0) -LocationX ($PWidth - 15) -LocationY 0
# Panels 1, 2, 3 ~> Title Label
$TitleLabel1 = Create-Label -Text "System Tweaks" -Width $TLWidth -Height $TLHeight -LocationX $TitleLabelX -LocationY $TitleLabelY -FontSize $FontSize4 -FontStyle "Bold"
@ -214,7 +214,7 @@ function Show-GUI() {
$JavaJRE = Create-Button -Text "Java JRE" -Width $SBWidth -Height $SBHeight -LocationX $ButtonX -LocationY $NextYLocation -FontSize $FontSize1
$NextYLocation = $JavaJRE.Location.Y + $JavaJRE.Height + $DistanceBetweenButtons
$JavaJDKs = Create-Button -Text "AdoptOpenJDK 8, 11 and 16" -Width $SBWidth -Height $SBHeight -LocationX $ButtonX -LocationY $NextYLocation -FontSize $FontSize1
$JavaJDKs = Create-Button -Text "AdoptiumJDK 8, 11 and 17" -Width $SBWidth -Height $SBHeight -LocationX $ButtonX -LocationY $NextYLocation -FontSize $FontSize1
$NextYLocation = $JavaJDKs.Location.Y + $JavaJDKs.Height + $DistanceBetweenButtons
$NodeJsLts = Create-Button -Text "NodeJS LTS" -Width $SBWidth -Height $SBHeight -LocationX $ButtonX -LocationY $NextYLocation -FontSize $FontSize1
@ -246,6 +246,9 @@ function Show-GUI() {
$NextYLocation = $PostgreSQL.Location.Y + $PostgreSQL.Height + $DistanceBetweenButtons
$MySQL = Create-Button -Text "MySQL" -Width $SBWidth -Height $SBHeight -LocationX $ButtonX -LocationY $NextYLocation -FontSize $FontSize1
$NextYLocation = $MySQL.Location.Y + $MySQL.Height + $DistanceBetweenButtons
$Insomnia = Create-Button -Text "Insomnia" -Width $SBWidth -Height $SBHeight -LocationX $ButtonX -LocationY $NextYLocation -FontSize $FontSize1
# Panel 3.2 ~> Big Button
$InstallGamingDependencies = Create-Button -Text "Install Gaming Dependencies" -Width $BBWidth -Height $BBHeight -LocationX $ButtonX -LocationY $FirstButtonY -FontSize $FontSize2 -FontStyle "Italic" -ForeColor $LightBlue
@ -308,8 +311,11 @@ function Show-GUI() {
$NextYLocation = $Parsec.Location.Y + $Parsec.Height + $DistanceBetweenButtons
$TeamViewer = Create-Button -Text "Team Viewer" -Width $SBWidth -Height $SBHeight -LocationX $ButtonX -LocationY $NextYLocation -FontSize $FontSize1
# Panel 3.2 ~> Caption Label
$NextYLocation = $TeamViewer.Location.Y + $TeamViewer.Height + $DistanceBetweenButtons
$AndroidScrCpy = Create-Button -Text "Android ScrCpy" -Width $SBWidth -Height $SBHeight -LocationX $ButtonX -LocationY $NextYLocation -FontSize $FontSize1
# Panel 3.2 ~> Caption Label
$NextYLocation = $AndroidScrCpy.Location.Y + $AndroidScrCpy.Height + $DistanceBetweenButtons
$CaptionLabel3_2_5 = Create-Label -Text "Streaming" -Width $CLWidth -Height $CLHeight -LocationX $ButtonX -LocationY $NextYLocation -FontSize $FontSize1
# Panel 3.2 ~> Small Buttons
@ -358,8 +364,11 @@ function Show-GUI() {
$NextYLocation = $CrystalDiskInfo.Location.Y + $CrystalDiskInfo.Height + $DistanceBetweenButtons
$CrystalDiskMark = Create-Button -Text "Crystal Disk Mark" -Width $SBWidth -Height $SBHeight -LocationX $ButtonX -LocationY $NextYLocation -FontSize $FontSize1
# Panel 3.2 ~> Caption Label
$NextYLocation = $CrystalDiskMark.Location.Y + $CrystalDiskMark.Height + $DistanceBetweenButtons
$NVCleanstall = Create-Button -Text "NVCleanstall" -Width $SBWidth -Height $SBHeight -LocationX $ButtonX -LocationY $NextYLocation -FontSize $FontSize1
# Panel 3.2 ~> Caption Label
$NextYLocation = $NVCleanstall.Location.Y + $NVCleanstall.Height + $DistanceBetweenButtons
$CaptionLabel3_2_9 = Create-Label -Text "WSL 2" -Width $CLWidth -Height $CLHeight -LocationX $ButtonX -LocationY $NextYLocation -FontSize $FontSize1
# Panel 3.2 ~> Small Buttons
@ -414,16 +423,16 @@ function Show-GUI() {
$Panel3_1.Controls.AddRange(@($CaptionLabel3_1_5, $VSCode, $NotepadPlusPlus))
$Panel3_1.Controls.AddRange(@($CaptionLabel3_1_6, $GoogleDrive, $Dropbox))
$Panel3_1.Controls.AddRange(@($CaptionLabel3_1_7, $AuthyDesktop))
$Panel3_1.Controls.AddRange(@($CaptionLabel3_1_8, $WindowsTerminal, $GitAndKeysSetup, $JavaJRE, $JavaJDKs, $NodeJsLts, $NodeJs, $Python3, $Anaconda3, $Ruby, $ADB, $AndroidStudio, $DockerDesktop, $PostgreSQL, $MySQL))
$Panel3_1.Controls.AddRange(@($CaptionLabel3_1_8, $WindowsTerminal, $GitAndKeysSetup, $JavaJRE, $JavaJDKs, $NodeJsLts, $NodeJs, $Python3, $Anaconda3, $Ruby, $ADB, $AndroidStudio, $DockerDesktop, $PostgreSQL, $MySQL, $Insomnia))
$Panel3_2.Controls.AddRange(@($TitleLabel4, $InstallGamingDependencies, $CaptionLabel3_2_1, $Discord, $MSTeams, $Slack, $Zoom, $RocketChat))
$Panel3_2.Controls.AddRange(@($CaptionLabel3_2_2, $Steam, $GogGalaxy, $EpicGames, $EADesktop, $UbisoftConnect))
$Panel3_2.Controls.AddRange(@($CaptionLabel3_2_3, $Notion))
$Panel3_2.Controls.AddRange(@($CaptionLabel3_2_4, $Parsec, $TeamViewer))
$Panel3_2.Controls.AddRange(@($CaptionLabel3_2_4, $Parsec, $TeamViewer, $AndroidScrCpy))
$Panel3_2.Controls.AddRange(@($CaptionLabel3_2_5, $ObsStudio, $StreamlabsObs))
$Panel3_2.Controls.AddRange(@($CaptionLabel3_2_6, $qBittorrent))
$Panel3_2.Controls.AddRange(@($CaptionLabel3_2_7, $Spotify, $Vlc, $MpcHc))
$Panel3_2.Controls.AddRange(@($CaptionLabel3_2_8, $CPUZ, $GPUZ, $CrystalDiskInfo, $CrystalDiskMark))
$Panel3_2.Controls.AddRange(@($CaptionLabel3_2_8, $CPUZ, $GPUZ, $CrystalDiskInfo, $CrystalDiskMark, $NVCleanstall))
$Panel3_2.Controls.AddRange(@($CaptionLabel3_2_9, $WSL2, $Ubuntu, $Debian, $KaliLinux, $OpenSuse, $SLES, $Ubuntu16LTS, $Ubuntu18LTS, $Ubuntu20LTS))
# <== CLICK EVENTS ==>
@ -746,8 +755,8 @@ function Show-GUI() {
Install-Package -Name $JavaJRE.Text -PackageName "Oracle.JavaRuntimeEnvironment"
})
$JavaJDKs.Add_Click( { # Be vigilant as Eclipse Adoptium will become the newest owner
Install-Package -Name $JavaJDKs.Text -PackageName @("AdoptOpenJDK.OpenJDK.8", "AdoptOpenJDK.OpenJDK.11", "AdoptOpenJDK.OpenJDK.16")
$JavaJDKs.Add_Click( {
Install-Package -Name $JavaJDKs.Text -PackageName @("EclipseAdoptium.Temurin.8", "EclipseAdoptium.Temurin.11", "EclipseAdoptium.Temurin.17")
})
$NodeJsLts.Add_Click( {
@ -790,6 +799,10 @@ function Show-GUI() {
Install-Package -Name $MySQL.Text -PackageName "Oracle.MySQL"
})
$Insomnia.Add_Click( {
Install-Package -Name $Insomnia.Text -PackageName "Insomnia.Insomnia"
})
$InstallGamingDependencies.Add_Click( {
Push-Location -Path "$PSScriptRoot\src\scripts\"
Get-ChildItem -Recurse *.ps*1 | Unblock-File
@ -859,6 +872,10 @@ function Show-GUI() {
Install-Package -Name $TeamViewer.Text -PackageName "TeamViewer.TeamViewer"
})
$AndroidScrCpy.Add_Click( {
Install-Package -Name $AndroidScrCpy.Text -PackageName "scrcpy" -InstallBlock { choco install -y $Package }
})
$ObsStudio.Add_Click( {
Install-Package -Name $ObsStudio.Text -PackageName "OBSProject.OBSStudio"
})
@ -899,6 +916,10 @@ function Show-GUI() {
Install-Package -Name $CrystalDiskMark.Text -PackageName "CrystalDewWorld.CrystalDiskMark"
})
$NVCleanstall.Add_Click( {
Install-Package -Name $NVCleanstall.Text -PackageName "TechPowerUp.NVCleanstall"
})
$WSL2.Add_Click( {
Push-Location "$PSScriptRoot\src\utils\"
@ -963,11 +984,12 @@ function Main() {
Import-Module -DisableNameChecking "$PSScriptRoot\src\lib\install-package.psm1"
Import-Module -DisableNameChecking "$PSScriptRoot\src\lib\gui-helper.psm1"
Import-Module -DisableNameChecking "$PSScriptRoot\src\lib\set-script-policy.psm1"
Import-Module -DisableNameChecking "$PSScriptRoot\src\lib\simple-message-box.psm1"
Import-Module -DisableNameChecking "$PSScriptRoot\src\lib\show-message-box.psm1"
Import-Module -DisableNameChecking "$PSScriptRoot\src\lib\title-templates.psm1"
Set-UnrestrictedPermissions # Unlock script usage
Import-Module -DisableNameChecking "$PSScriptRoot\src\scripts\install-package-managers.ps1" -Force # Install Winget and Chocolatey at the beginning
Write-ASCIIScriptName # Thanks Figlet
Show-GUI # Load the GUI
Write-Verbose "Restart: $Global:NeedRestart"

@ -11,29 +11,31 @@ function Show-Message() {
[CmdletBinding()] #<<-- This turns a regular function into an advanced function
param (
[String] $Title = "Insert title here",
[Array] $Message =
[String] $Title = "Insert title here",
[Array] $Message =
"Crash
Bandicoot"
Bandicoot",
[String] $BoxButtons = "OK", # AbortRetryIgnore, OK, OKCancel, RetryCancel, YesNo, YesNoCancel,
[String] $BoxIcon = "Information" # Information, Question, Warning, Error or None
)
Use-SysForms
[System.Windows.Forms.MessageBox]::Show($Message, $Title, [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Information)
[System.Windows.Forms.MessageBox]::Show($Message, $Title, [System.Windows.Forms.MessageBoxButtons]::$BoxButtons, [System.Windows.Forms.MessageBoxIcon]::$BoxIcon)
}
# Demo: Show-Message -Title "Title" -Message "Message"
function Show-Question() {
param (
[String] $Title = "Insert title here",
[Array] $Message =
[String] $Title = "Insert title here",
[Array] $Message =
"Crash
Bandicoot"
Bandicoot",
[String] $BoxButtons = "YesNoCancel",
[String] $BoxIcon = "Question"
)
Use-SysForms
$Answer = [System.Windows.Forms.MessageBox]::Show($Message, $Title, [System.Windows.Forms.MessageBoxButtons]::YesNoCancel, [System.Windows.Forms.MessageBoxIcon]::Question)
$Answer = [System.Windows.Forms.MessageBox]::Show($Message, $Title, [System.Windows.Forms.MessageBoxButtons]::$BoxButtons, [System.Windows.Forms.MessageBoxIcon]::$BoxIcon)
return $Answer
}
@ -43,7 +45,7 @@ function Request-PcRestart() {
$Ask = "If you want to see the changes restart your computer!
Do you want to Restart now?"
switch (Show-Question -Title "Read carefully" -Message $Ask) {
switch (Show-Question -Title "Warning" -Message $Ask) {
'Yes' {
Write-Host "You choose to Restart now"
Restart-Computer
@ -60,6 +62,7 @@ function Request-PcRestart() {
<#
Example:
Show-Message -Title "Title" -Message "Message"
$Question = Show-Question -Title "Title" -Message "Message"
Returns Yes or No or Cancel
#>

@ -5,9 +5,7 @@ function Write-Title() {
[String] $Text = "Write-Title Text"
)
Write-Host "" # Skip line
Write-Host "<====================[ $Text ]====================>" -ForegroundColor Cyan
Write-Host "" # Skip line
Write-Host "`n<====================[ $Text ]====================>`n" -ForegroundColor Cyan
}
function Write-Section() {
@ -17,9 +15,7 @@ function Write-Section() {
[String] $Text = "Write-Section Text"
)
Write-Host "" # Skip line
Write-Host "<==========[ $Text ]==========>" -ForegroundColor Cyan
Write-Host "" # Skip line
Write-Host "`n<==========[ $Text ]==========>`n" -ForegroundColor Cyan
}
function Write-Caption() {
@ -29,8 +25,7 @@ function Write-Caption() {
[String] $Text = "Write-Caption Text"
)
Write-Host "--> $Text" -ForegroundColor Cyan
Write-Host "" # Skip line
Write-Host "--> $Text`n" -ForegroundColor Cyan
}
function Write-TitleCounter() {
@ -49,9 +44,7 @@ function Write-TitleCounter() {
}
$Global:Counter = $Counter + 1
Write-Host "" # Skip line
Write-Host "<====================< ( $Counter/$MaxNum ) - [$Text] >====================>" -ForegroundColor Yellow
Write-Host "" # Skip line
Write-Host "`n<====================< ( $Counter/$MaxNum ) - [$Text] >====================>`n" -ForegroundColor Yellow
# Reset both when the Counter is greater or equal than MaxNum and different from 0
If (($Counter -ge $MaxNum) -and !($Counter -eq 0)) {
@ -60,10 +53,30 @@ function Write-TitleCounter() {
}
}
function Write-ASCIIScriptName() {
[CmdletBinding()] #<<-- This turns a regular function into an advanced function
param ()
Write-Host ' __ __ _ _ ___ ____ _ ' -ForegroundColor Cyan
Write-Host ' \ \ / /(_) _ __ / | / _ \ _ / ___| _ __ ___ __ _ _ __ | |_ ' -ForegroundColor Cyan
Write-Host ' \ \ /\ / / | || "_ \ | || | | | _| |_ \___ \ | "_ ` _ \ / _` || "__|| __| ' -ForegroundColor Cyan
Write-Host ' \ V V / | || | | || || |_| ||_ _| ___) || | | | | || (_| || | | |_ ' -ForegroundColor Cyan
Write-Host ' \_/\_/ |_||_| |_||_| \___/ |_| |____/ |_| |_| |_| \__,_||_| \__| ' -ForegroundColor Cyan
Write-Host ' ' -ForegroundColor Cyan
Write-Host ' ____ _ _ _ ' -ForegroundColor Cyan
Write-Host ' | _ \ ___ | |__ | | ___ __ _ | |_ ' -ForegroundColor Cyan
Write-Host ' | | | | / _ \| "_ \ | | / _ \ / _` || __| ' -ForegroundColor Cyan
Write-Host ' | |_| || __/| |_) || || (_) || (_| || |_ ' -ForegroundColor Cyan
Write-Host " |____/ \___||_.__/ |_| \___/ \__,_| \__| `n`n" -ForegroundColor Cyan
}
<#
Example:
Write-Title -Text "Text"
Write-Section -Text "Text"
Write-Caption -Text "Text"
Write-TitleCounter -Text "Text" -MaxNum 100 # First time only insert MaxNum
Write-ASCIIScriptName
#>

@ -1,15 +1,15 @@
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\"get-os-info.psm1"
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\"simple-message-box.psm1"
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\"show-message-box.psm1"
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\"title-templates.psm1"
function Install-DriversUpdaters() {
$Ask = "Do you plan to play games on this PC?
All the following Driver Updaters will be installed:
+ $CPU driver updater (if found)
+ $GPU driver updater (if found)"
- $CPU driver updater (if found)
- $GPU driver updater (if found)"
switch (Show-Question -Title "Read carefully" -Message $Ask) {
switch (Show-Question -Title "Warning" -Message $Ask) {
'Yes' {
# Check for CPU drivers
If ($CPU.contains("AMD")) {

@ -1,15 +1,15 @@
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\"simple-message-box.psm1"
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\"show-message-box.psm1"
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\"title-templates.psm1"
function Install-GamingPackages() {
$Ask = "Do you plan to play games on this PC?
All the following Gaming Dependencies will be installed:
+ Microsoft DirectX
+ Microsoft .NET (Framework, Runtime & SDK)
+ Microsoft Visual C++ Packages (2005-2022)"
- Microsoft DirectX
- Microsoft .NET (Framework, Runtime & SDK)
- Microsoft Visual C++ Packages (2005-2022)"
switch (Show-Question -Title "Read carefully" -Message $Ask) {
switch (Show-Question -Title "Warning" -Message $Ask) {
'Yes' {
Write-Host "You choose Yes."
$ChocoGamingPackages = @(

@ -1,5 +1,5 @@
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\"remove-uwp-apps.psm1"
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\"simple-message-box.psm1"
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\"show-message-box.psm1"
function Remove-Xbox() {
@ -8,9 +8,11 @@ function Remove-Xbox() {
$Ask = "This will remove the Xbox:
- Apps;
- Services (Except from Accessories) and;
- GameBar/GameDVR."
- GameBar/GameDVR.
switch (Show-Question -Title "Warning" -Message $Ask) {
Do you want to proceed?"
switch (Show-Question -Title "Warning" -Message $Ask -BoxIcon "Warning") {
'Yes' {
Write-Host "[-][Services] Disabling Xbox Services (Except from Accessories)..."

Loading…
Cancel
Save