webhelper/webhelper.nsi
2025-05-25 02:40:12 +08:00

77 lines
No EOL
1.9 KiB
NSIS
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

!include "MUI2.nsh"
Unicode true
Name "OGBG WebHelper"
OutFile "webhelper.exe"
InstallDir "X:\path\to\pubg\TslGame\Binaries\Win64"
RequestExecutionLevel admin
!define MUI_ABORTWARNING
!define MUI_LANGDLL_ALLLANGUAGES
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
!define MUI_LANGDLL_REGISTRY_KEY "Software\OGBG WebHelper"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "SimpChinese"
LangString InvalidDirMessage ${LANG_ENGLISH} "The selected directory does not contain TslGame.exe. Please select a valid directory."
LangString InvalidDirMessage ${LANG_SIMPCHINESE} "选择的目录中未找到 TslGame.exe请选择有效目录。"
Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd
Function DirectoryValidate
IfFileExists "$INSTDIR\TslGame.exe" 0 +2
Return
MessageBox MB_OK|MB_ICONEXCLAMATION "$(InvalidDirMessage)"
Abort
FunctionEnd
Function un.DeleteRegKeyRecursive
Exch $0
ClearErrors
FindFirst $1 $2 "HKCR\$0\*"
StrCmp $1 "" 0 +3
FindClose $2
Goto done
loop:
Push "$0\$1"
Call un.DeleteRegKeyRecursive
FindNext $1 $2
IfErrors done
Goto loop
done:
FindClose $2
DeleteRegKey HKCR "$0"
Pop $0
FunctionEnd
Section "Install"
Call DirectoryValidate
SetOutPath "$INSTDIR"
File /oname=helper.exe "x64\Debug\helper.exe"
WriteRegStr HKCR "ogbg" "URL Protocol" ""
WriteRegStr HKCR "ogbg" "" "OGBG WebHelper Protocol"
WriteRegStr HKCR "ogbg\shell\open\command" "" '"$INSTDIR\helper.exe" "%1"'
WriteUninstaller "$INSTDIR\Uninstall.exe"
SectionEnd
Section "Uninstall"
Delete "$INSTDIR\helper.exe"
DeleteRegKey /ifempty HKCR "pubggame"
Push "ogbg"
Call un.DeleteRegKeyRecursive
Exec '"$WINDIR\System32\cmd.exe" /C ping 127.0.0.1 -n 2 > nul & del /f /q "$INSTDIR\Uninstall.exe"'
SectionEnd