Browse Source

Fix script allowing itself to run as admin

master
LoganDark 2 years ago
parent
commit
35009cea98
1 changed files with 13 additions and 0 deletions
  1. +13
    -0
      InstallWSL.psm1

+ 13
- 0
InstallWSL.psm1 View File

@ -334,6 +334,10 @@ function Install-WSLInteractive {
$Menu = 'main'
if ([Security.Principal.WindowsIdentity]::GetCurrent().Groups -contains 'S-1-5-32-544') {
$Menu = 'admin'
}
while ($Menu -ne 'exit') {
Clear-Host
# 80 chars: ' '
@ -465,6 +469,15 @@ function Install-WSLInteractive {
$Host.UI.ReadLine()
$Menu = 'main'
}
'admin' {
Write-Output ''
Write-Host ' !! This script should NOT be run as Administrator' -ForegroundColor Red
Write-Host ' !! Please close this window and run the script normally' -ForegroundColor Red
Write-Output ''
Write-Host ' Press enter to continue...' -NoNewLine
$Host.UI.ReadLine()
$Menu = 'exit'
}
default {
Write-Output ''
Write-Host " !! Invalid menu encountered ($Menu). Exiting" -ForegroundColor Red


Loading…
Cancel
Save