W4RH4WK / Debloat-Windows-10

A Collection of Scripts Which Disable / Remove Windows 10 Features and Apps
Other
6.03k stars 851 forks source link

self run as administrator #237

Closed Mod4rchive closed 4 years ago

Mod4rchive commented 4 years ago

add this lines to make the scripts easier to run with just only "Run with Powershell" left-click option

$principal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
if($principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
    # code here...
}
else {
    Start-Process -FilePath "powershell" -ArgumentList "$('-File ""')$(Get-Location)$('\')$($MyInvocation.MyCommand.Name)$('""')" -Verb runAs
}

sorry im new at git i dont know how to make push requests

W4RH4WK commented 4 years ago

Thank you for the input. This a nice convenience improvement; however, I expect the target audience to know that the scripts have to be invoked from an account with administrator privileges. That's stated in the README as well.

I prefer not to add additional logic just out of convenience to the scripts. They already fiddle with enough complex stuff.