I want to make a GUI for my Powershell scripts so others can easily use them too. I have a main-menu script witch calls some other scripts. For one of them I needed an elevated Powershell process.
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSFilePath`"" -Verb RunAs; exit }
Now my problem is, that not only the GUI from $PSFilePath is shown but also an empty console window in the background
I tried to use -WindowStyle Hidden
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSFilePath`"" -WindowStyle Hidden -Verb RunAs; exit }
But that resulted in both the console and the GUI being hidden.
Anyway to hide that console window but not the GUI?