MysticFoxDE / WINDOWS-OPTIMIZATIONS

SKRIPTS FOR WINDOWS DESUBOPTIMIZATION
606 stars 54 forks source link

Add auto elevation #8

Closed Karl-WE closed 1 year ago

Karl-WE commented 1 year ago

This would allow the script to run with a right click, disregarding manual elevation

This comes handy in Windows Terminal or Explorer Context Menu run script, both aren't elevated by default.

if (-not (New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))

{ # Prompt the user to elevate the script $arguments = "& '" + $myInvocation.MyCommand.Definition + "'" Start-Process powershell -Verb runAs -ArgumentList $arguments exit }

your code here

MysticFoxDE commented 1 year ago

Hi Karl,

danke für den Tipp.

Ich habe den Part in den Code eingebaut, aber wenn ich das Script "automatisch" laufen lasse, kommt noch das folgende Meckern. 😬

"Die Datei "C:\WORK\WINDOWS10AND11-NETWORK-DESUBUPTIMIZATION V1.12.ps1" kann nicht geladen werden, da die Ausführung von Skripts auf diesem System deaktiviert ist. Weitere Informationen finden Sie unter "about_Execution_Policies""

Das lässt sich doch innerhalb des Skripts selbst gar nicht umgehen, oder?

Gruss Alex

MysticFoxDE commented 1 year ago

Hi Karl, dein "auto elevation" Vorschlag habe ich soeben übernommen. Vielen Dank dafür. Gruss Alex

tillewolle commented 1 year ago

Works great! But it closes the shell after it ran. Can you disable that? So you can see errors and stats.

Karl-WE commented 1 year ago

You can add break or sleep at the end