-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLaunch AutoFix.cmd
29 lines (22 loc) · 1.05 KB
/
Launch AutoFix.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
@echo off
::Attain necessary permission
call :elevate || exit /b 1
::Start main-----------------------------------------------------------------------------------------------------::
::PowerShell command chaining used "command1 | &{command2}" because semicolon is used as a Windows Terminal syntax
set "filePath='%~dp0\AutoFix.ps1'"
set "command=Set-ExecutionPolicy Bypass -Scope Process^| ^&{^&%filePath%}"
if "%WT_SESSION%"=="" (
wt.exe -p "Windows PowerShell" powershell.exe -Command %command% 2>nul && exit /b 0
wtd.exe -p "Windows PowerShell" powershell.exe -Command %command% 2>nul && exit /b 0
pause
)
powershell.exe -Command %command% 2>nul && exit /b 0
exit /b 1
::End main-------------------------------------------------------------------------------------------------------::
:elevate
whoami /groups |find " S-1-16-12288 " >nul 2>&1 && exit /b 0
echo/Admin privilege is required.
echo/Requesting administrative privilege...
powershell Start-Process '%~s0' -Verb runAs
if %ErrorLevel% neq 0 echo/User denied the request. && pause && exit /b 1
exit /b 2