2022-04-24 04:29:48 +00:00
|
|
|
@echo off
|
2022-04-20 02:46:21 +00:00
|
|
|
|
2022-04-21 10:40:54 +00:00
|
|
|
:: Ensure admin
|
2022-04-26 00:21:35 +00:00
|
|
|
@REM >nul 2>&1 reg query "HKU\S-1-5-19" || (
|
|
|
|
@REM set params = %*:"="""%
|
|
|
|
@REM cd /d "%~dp0" && ( if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" ) && fsutil dirty query %systemdrive% 1>nul 2>nul || ( echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~sdp0"" && %~s0 %1 %2 %3 "%4" ""%cd%"" %6", "", "runas", 1 >> "%temp%\getadmin.vbs" && "%temp%\getadmin.vbs" && exit /B )
|
|
|
|
@REM )
|
|
|
|
|
2022-04-23 08:10:39 +00:00
|
|
|
:: Use to force task kill
|
|
|
|
title PS Launcher Script
|
|
|
|
|
2022-04-20 02:46:21 +00:00
|
|
|
echo Starting Proxy Server
|
|
|
|
|
2022-04-21 10:45:41 +00:00
|
|
|
set IP=%1
|
2022-04-24 07:32:17 +00:00
|
|
|
set PORT=%2
|
2022-04-24 23:22:23 +00:00
|
|
|
set USE_HTTPS=%3
|
|
|
|
set GAME_PATH=%4
|
2022-04-21 10:45:41 +00:00
|
|
|
set GAME_PATH=%GAME_PATH:"=%
|
2022-04-24 23:22:23 +00:00
|
|
|
set ORIGIN=%5
|
2022-04-21 10:44:31 +00:00
|
|
|
set ORIGIN=%ORIGIN:"=%
|
2022-04-24 23:22:23 +00:00
|
|
|
set ENABLE_KILLSWITCH=%6
|
2022-04-20 02:46:21 +00:00
|
|
|
|
2022-04-27 08:33:53 +00:00
|
|
|
:: For registry
|
|
|
|
set GAME_REG="HKEY_CURRENT_USER\Software\miHoYo\Genshin Impact"
|
|
|
|
|
2022-04-26 00:38:10 +00:00
|
|
|
if "%ENABLE_KILLSWITCH%" EQU "true" (
|
|
|
|
:: Restart in elevated if need be
|
|
|
|
>nul 2>&1 reg query "HKU\S-1-5-19" || (
|
|
|
|
set params = %*:"="""%
|
|
|
|
cd /d "%~dp0" && ( if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" ) && fsutil dirty query %systemdrive% 1>nul 2>nul || ( echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~sdp0"" && %~s0 %1 %2 %3 "%4" ""%cd%/../"" %6", "", "runas", 1 >> "%temp%\getadmin.vbs" && "%temp%\getadmin.vbs" && taskkill /f /fi "WINDOWTITLE eq PS Launcher Script" && exit /b )
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2022-04-20 02:46:21 +00:00
|
|
|
set PROXY=true
|
|
|
|
@rem Store original proxy settings
|
|
|
|
for /f "tokens=2*" %%a in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable 2^>nul') do set "ORIG_PROXY_ENABLE=%%b"
|
|
|
|
for /f "tokens=2*" %%a in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer 2^>nul') do set "ORIG_PROXY_SERVER=%%b"
|
|
|
|
|
|
|
|
:: Set proxy settings in Windows
|
|
|
|
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f >nul 2>nul
|
|
|
|
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "127.0.0.1:8080" /f >nul 2>nul
|
|
|
|
|
2022-04-20 02:53:30 +00:00
|
|
|
:: Start proxy server
|
2022-04-30 09:51:10 +00:00
|
|
|
start "Proxy Server" "%ORIGIN%/ext/mitmdump.exe" -s "%ORIGIN%/proxy/proxy.py" -k --allow-hosts ".*\.yuanshen\.com|.*\.mihoyo\.com|.*\.hoyoverse\.com" --ssl-insecure --set ip=%IP% --set port=%PORT% --set use_https=%USE_HTTPS%
|
2022-04-20 02:46:21 +00:00
|
|
|
|
2022-04-21 10:45:41 +00:00
|
|
|
echo Opening %GAME_PATH%
|
2022-04-20 02:46:21 +00:00
|
|
|
|
2022-04-24 04:27:39 +00:00
|
|
|
:: Allow the proxy server to open fully
|
2022-04-21 03:22:10 +00:00
|
|
|
ping 127.0.0.1 -n 5 > nul
|
|
|
|
|
2022-04-21 22:23:52 +00:00
|
|
|
for %%A in ("%GAME_PATH%") do (
|
|
|
|
set GAME_EXE=%%~nxA
|
2022-04-21 10:40:54 +00:00
|
|
|
)
|
|
|
|
|
2022-04-21 22:23:52 +00:00
|
|
|
echo Killswitch: %ENABLE_KILLSWITCH%
|
|
|
|
|
|
|
|
if "%ENABLE_KILLSWITCH%" EQU "true" (
|
|
|
|
echo Killswitch is enabled!
|
|
|
|
:: Start killswitch
|
2022-04-26 00:38:10 +00:00
|
|
|
start /b %ORIGIN%\scripts\killswitch.cmd "%GAME_EXE%" %IP%
|
2022-04-21 22:23:52 +00:00
|
|
|
)
|
2022-04-21 10:40:54 +00:00
|
|
|
|
2022-04-20 02:53:30 +00:00
|
|
|
:: Launch game
|
2022-04-21 10:45:41 +00:00
|
|
|
"%GAME_PATH%"
|
2022-04-20 02:46:21 +00:00
|
|
|
|
2022-04-20 02:53:30 +00:00
|
|
|
:: On exit clean proxy stuff
|
2022-04-20 02:46:21 +00:00
|
|
|
:EXIT
|
2022-04-24 04:27:39 +00:00
|
|
|
echo Exiting...
|
|
|
|
|
|
|
|
if "%PROXY%" EQU "" (
|
2022-04-20 02:46:21 +00:00
|
|
|
echo Proxy not started, no need to clean up.
|
2022-04-20 02:53:30 +00:00
|
|
|
|
2022-04-24 04:27:39 +00:00
|
|
|
exit /b
|
|
|
|
)
|
|
|
|
|
|
|
|
:: Clean proxy settings
|
|
|
|
echo Cleaning up proxy settings...
|
|
|
|
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d "%ORIG_PROXY_ENABLE%" /f >nul 2>nul
|
|
|
|
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "%ORIG_PROXY_SERVER%" /f >nul 2>nul
|
|
|
|
|
|
|
|
:: Kill proxy server
|
|
|
|
taskkill /f /im mitmdump.exe
|
2022-04-21 10:40:54 +00:00
|
|
|
|
2022-04-26 00:21:35 +00:00
|
|
|
echo Done, see you next time
|
2022-04-23 08:10:39 +00:00
|
|
|
|
2022-04-26 01:39:43 +00:00
|
|
|
:: Just in case the user has corutils installed, use this hacky timeout instead of the timeout command
|
2022-04-30 05:45:14 +00:00
|
|
|
ping 127.0.0.1 -n 1 > nul
|
2022-04-26 01:51:53 +00:00
|
|
|
|
|
|
|
:: Attempt to kill either
|
|
|
|
taskkill /f /fi "WINDOWTITLE eq Administrator: PS Launcher Script"
|
|
|
|
taskkill /f /fi "WINDOWTITLE eq PS Launcher Script"
|
2022-04-23 08:10:39 +00:00
|
|
|
|
2022-04-24 04:27:39 +00:00
|
|
|
exit /b
|