mirror of
https://github.com/Sycnex/Windows10Debloater.git
synced 2025-03-12 18:05:29 +00:00
Merge 9086e562ec
into a48b4d8dc5
This commit is contained in:
commit
6820b32ff0
@ -10,8 +10,12 @@ $EnableEdgePDFTakeover.Location = New-Object System.Drawing.Point(155, 260)
|
|||||||
|
|
||||||
$ErrorActionPreference = 'SilentlyContinue'
|
$ErrorActionPreference = 'SilentlyContinue'
|
||||||
|
|
||||||
$Button = [System.Windows.MessageBoxButton]::YesNoCancel
|
## The following four lines only need to be declared once in your script.
|
||||||
$ErrorIco = [System.Windows.MessageBoxImage]::Error
|
$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes","Description."
|
||||||
|
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No","Description."
|
||||||
|
$cancel = New-Object System.Management.Automation.Host.ChoiceDescription "&Cancel","Description."
|
||||||
|
$options = [System.Management.Automation.Host.ChoiceDescription[]]($no, $yes, $cancel)
|
||||||
|
|
||||||
$Ask = 'Do you want to run this as an Administrator?
|
$Ask = 'Do you want to run this as an Administrator?
|
||||||
|
|
||||||
Select "Yes" to Run as an Administrator
|
Select "Yes" to Run as an Administrator
|
||||||
@ -20,16 +24,17 @@ $Ask = 'Do you want to run this as an Administrator?
|
|||||||
|
|
||||||
Select "Cancel" to stop the script.'
|
Select "Cancel" to stop the script.'
|
||||||
|
|
||||||
|
|
||||||
If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator')) {
|
If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator')) {
|
||||||
$Prompt = [System.Windows.MessageBox]::Show($Ask, "Run as an Administrator or not?", $Button, $ErrorIco)
|
$Prompt = $host.ui.PromptForChoice($Ask, "Run as an Administrator or not?", $options, 1)
|
||||||
Switch ($Prompt) {
|
Switch ($Prompt) {
|
||||||
#This will debloat Windows 10
|
#This will debloat Windows 10
|
||||||
Yes {
|
1 { #Yes
|
||||||
Write-Host "You didn't run this script as an Administrator. This script will self elevate to run as an Administrator and continue."
|
Write-Host "You didn't run this script as an Administrator. This script will self elevate to run as an Administrator and continue."
|
||||||
Start-Process PowerShell.exe -ArgumentList ("-NoProfile -ExecutionPolicy Bypass -File `"{0}`"" -f $PSCommandPath) -Verb RunAs
|
Start-Process PowerShell.exe -ArgumentList ("-NoProfile -ExecutionPolicy Bypass -File `"{0}`"" -f $PSCommandPath) -Verb RunAs
|
||||||
Exit
|
Exit
|
||||||
}
|
}
|
||||||
No {
|
default {
|
||||||
Break
|
Break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user