mirror of
https://github.com/Sycnex/Windows10Debloater.git
synced 2024-11-24 11:45:29 +00:00
Added Self elevation to run as administrator
I added code to perform self elevation asking for the script to be run as an Administrator, otherwise the script will not be able to perform at its best. This resolves issue #73
This commit is contained in:
parent
0c2ee7149b
commit
5db2bcd378
@ -1,6 +1,15 @@
|
||||
#This function finds any AppX/AppXProvisioned package and uninstalls it, except for Freshpaint, Windows Calculator, Windows Store, and Windows Photos.
|
||||
#Also, to note - This does NOT remove essential system services/software/etc such as .NET framework installations, Cortana, Edge, etc.
|
||||
|
||||
#This will self elevate the script so with a UAC prompt since this script needs to be run as an Administrator in order to function properly.
|
||||
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
|
||||
$arguments = "&" + $MyInvocation.MyCommand.Definition + ""
|
||||
Write-Host "You didn't run this script as an Administrator. This script will self elevate to run as an Administrator." -ForegroundColor "White"
|
||||
Start-Sleep 1
|
||||
Start-Process "powershell.exe" -Verb RunAs -ArgumentList $arguments
|
||||
Break
|
||||
}
|
||||
|
||||
#no errors throughout
|
||||
$ErrorActionPreference = 'silentlycontinue'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user