diff --git a/scripts/killswitch.cmd b/scripts/killswitch.cmd index 9c1465f..af9e60e 100644 --- a/scripts/killswitch.cmd +++ b/scripts/killswitch.cmd @@ -23,10 +23,10 @@ if "%PROXY_IP%" EQU "localhost" ( :loop :: Check if the game is even running - @rem QPROCESS "%GAME_EXE_NAME%">NUL - @rem IF %ERRORLEVEL% NEQ 0 ( - @rem exit /b - @rem ) + :: tasklist /fi "ImageName eq %GAME_EXE_NAME%" /fo csv 2>NUL | find /I "%GAME_EXE_NAME%.exe">NUL + :: IF %ERRORLEVEL% NEQ 0 ( + :: exit /b + :: ) :: Check if the proxy server process is running :: https://stackoverflow.com/questions/162291/how-to-check-if-a-process-is-running-via-a-batch-script @@ -87,6 +87,6 @@ if "%PROXY_IP%" EQU "localhost" ( :: Reconnect to the WiFi netsh wlan connect name="%WIFI%" - taskkill /f /fi "WINDOWTITLE eq Administrator: PS Killswitch" + :: taskkill /f /fi "WINDOWTITLE eq Administrator: PS Killswitch" exit \ No newline at end of file diff --git a/scripts/private_server_launch.cmd b/scripts/private_server_launch.cmd index 1a15d66..50315bf 100644 --- a/scripts/private_server_launch.cmd +++ b/scripts/private_server_launch.cmd @@ -1,4 +1,4 @@ -@echo off +:: @echo off :: Ensure admin >nul 2>&1 reg query "HKU\S-1-5-19" || ( @@ -32,7 +32,7 @@ start "Proxy Server" %ORIGIN%/ext/mitmdump.exe -s "%ORIGIN%/proxy/proxy.py" --ss echo Opening %GAME_PATH% -:: Allow the proxy server to create the certificates +:: Allow the proxy server to open fully ping 127.0.0.1 -n 5 > nul for %%A in ("%GAME_PATH%") do ( @@ -52,21 +52,26 @@ if "%ENABLE_KILLSWITCH%" EQU "true" ( :: On exit clean proxy stuff :EXIT -if "%PROXY%" == "" ( +echo Exiting... + +if "%PROXY%" EQU "" ( echo Proxy not started, no need to clean up. -) else ( - :: 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 + exit /b +) - echo Done! See you next time! +:: 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 - timeout /t 2 /nobreak >nul - taskkill /f /fi "WINDOWTITLE eq Administrator: PS Launcher Script" +:: Kill proxy server +taskkill /f /im mitmdump.exe - exit /b -) \ No newline at end of file +echo Done! See you next time! + +timeout /t 2 /nobreak >nul + +:: taskkill /f /fi "WINDOWTITLE eq Administrator: PS Launcher Script" + +exit /b \ No newline at end of file