self_-_elevation
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| self_-_elevation [2022/01/13 20:45] – created oso | self_-_elevation [2024/10/17 21:42] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| <code powershell> | <code powershell> | ||
| - | # Self-elevate the script if required | + | # Self-elevate the script if required |
| if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]:: | if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]:: | ||
| - | if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) { | + | |
| - | $CommandLine = "-File `"" | + | $CommandLine = "-File `"" |
| - | Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine | + | Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine |
| - | Exit | + | Exit |
| - | | + | } |
| } | } | ||
| </ | </ | ||
self_-_elevation.1642106707.txt.gz · Last modified: 2024/10/17 21:42 (external edit)
