@echo off
title proxy_gate

setlocal
set uac=~uac_permission_tmp_%random%
md "%SystemRoot%\system32\%uac%" 2>nul
if %errorlevel%==0 ( rd "%SystemRoot%\system32\%uac%" >nul 2>nul ) else (
    echo set uac = CreateObject^("Shell.Application"^)>"%temp%\%uac%.vbs"
    echo uac.ShellExecute "%~s0","","","runas",1 >>"%temp%\%uac%.vbs"
    echo WScript.Quit >>"%temp%\%uac%.vbs"
    "%temp%\%uac%.vbs" /f
    del /f /q "%temp%\%uac%.vbs" & exit )
endlocal  

:BG
cls
echo ©°©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©´
echo ©¦                        proxy_gate                           ©¦
echo ©À©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©È
echo ©¦                                                             ©¦
echo ©¦INS USE                                                      ©¦
echo ©¦        install    install proxy_gate as service (use nssm)  ©¦
echo ©¦        uninstall  uninstall proxy_gate service              ©¦
echo ©¦        start      start proxy_gate service (after install)  ©¦
echo ©¦        stop       stop proxy_gate service                   ©¦
echo ©¦        reload     reload config file                        ©¦
echo ©¦                                                             ©¦
echo ©¸©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¼

%~d0
cd %~dp0
::SET select=
SET /P select="Please Enter Instructions:"

IF "%select%"=="install" (
	%~dp0\\nssm.exe install proxy_gate %~dp0\\proxy_gate.exe -s start
	pause
	GOTO BG
) ELSE ( 
	IF "%select%"=="start" (
		net start proxy_gate
		pause
		GOTO BG
	) ELSE (
		IF "%select%"=="stop" (
			%~dp0\\proxy_gate.exe -s stop
			net stop proxy_gate 
			pause
			GOTO BG
		) ELSE (
			IF "%select%"=="reload" (
				%~dp0\\proxy_gate.exe -s reload
				pause
				GOTO BG
			) ELSE (
				IF "%select%"=="uninstall" (
					sc delete proxy_gate 
					pause
					GOTO BG
				) ELSE (
					 echo Param Error Try Again!
					 pause
					 GOTO BG
					)
				) 
			) 
		) 
	) 
)

pause

exit