Skip to content
This repository has been archived by the owner on Jul 5, 2022. It is now read-only.

Backup and restore registry for seamless transition #79

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backups/registries/registry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

19 changes: 18 additions & 1 deletion scripts/private_server_launch.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ set ORIGIN=%5
set ORIGIN=%ORIGIN:"=%
set ENABLE_KILLSWITCH=%6

:: For registry backups
set BACKUPS=%ORIGIN%\backups

:: For registry
set GAME_REG="HKEY_CURRENT_USER\Software\miHoYo\Genshin Impact"

Expand All @@ -34,6 +37,14 @@ if "%ENABLE_KILLSWITCH%" EQU "true" (
)
)

:: Backup official registry
regedit /E "%BACKUPS%\registries\official.reg" %GAME_REG%

:: Restore private server registry if exist
IF exist %BACKUPS%\registries\ps.reg (
regedit /S "%BACKUPS%\registries\ps.reg"
)

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"
Expand Down Expand Up @@ -76,6 +87,12 @@ if "%PROXY%" EQU "" (
exit /b
)

:: Backup private server registry
regedit /E "%BACKUPS%\registries\ps.reg" %GAME_REG%

:: Restore official registry
regedit /S "%BACKUPS%\registries\official.reg"

:: 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
Expand All @@ -93,4 +110,4 @@ ping 127.0.0.1 -n 2 > nul
taskkill /f /fi "WINDOWTITLE eq Administrator: PS Launcher Script"
taskkill /f /fi "WINDOWTITLE eq PS Launcher Script"

exit /b
exit /b