-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhost.bat
49 lines (35 loc) · 1.69 KB
/
host.bat
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
REM --> add the following to the top of your bat file--
@echo off
:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
echo Checking administrative privileges ...
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges ...
goto UACPrompt
) else (
echo Got administrative privileges ...
goto gotAdmin
)
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:gotAdmin
SET NEWLINE=^& echo.
ECHO %NEWLINE%^# Added by Project Larabeans>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "larabeans.ts" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^127.0.0.1 larabeans.ts>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "mysql.larabeans.ts" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^127.0.0.1 mysql.larabeans.ts>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "api.larabeans.ts" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^127.0.0.1 api.larabeans.ts>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "admin.api.larabeans.ts" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^127.0.0.1 admin.larabeans.ts>>%WINDIR%\System32\drivers\etc\hosts
ECHO %NEWLINE%^# End of section>>%WINDIR%\System32\drivers\etc\hosts
:--------------------------------------