From a01a16a9f1fbb5121ebfc44f75da62c46070d053 Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Sat, 4 Sep 2021 08:01:57 +0200 Subject: [PATCH] Build: Install scripts will request admin privileges and patch unrelated files can be automatically voided for test session (#175) * Install scripts will now request admin privileges to make install easier for users who have game installed on C drive * Add user configurable list of files that are automatically voided (renamed) before starting game for testing --- Patch104pZH/MAKE_Install.bat | 27 +++++++++++++++++ Patch104pZH/MAKE_Install_Run.bat | 41 ++++++++++++++++++++++++++ Patch104pZH/SETUP_UserSettings.bat.txt | 25 ++++++++++++++++ 3 files changed, 93 insertions(+) diff --git a/Patch104pZH/MAKE_Install.bat b/Patch104pZH/MAKE_Install.bat index 6691ede1d..4e3220d9c 100644 --- a/Patch104pZH/MAKE_Install.bat +++ b/Patch104pZH/MAKE_Install.bat @@ -1,3 +1,30 @@ +@echo off +:: BatchGotAdmin +:------------------------------------- +:: --> Check for permissions +>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" + +:: --> If error flag set, we do not have admin. +if '%errorlevel%' NEQ '0' ( + echo Requesting administrative privileges... + goto UACPrompt +) else ( goto gotAdmin ) + +:UACPrompt + echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" + set params = %*:"="" + echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" + + "%temp%\getadmin.vbs" + del "%temp%\getadmin.vbs" + exit /B + +:gotAdmin + pushd "%CD%" + CD /D "%~dp0" +:-------------------------------------- +echo on + call MAKE_Patch104pZH.bat call SETUP_UserSettings.bat diff --git a/Patch104pZH/MAKE_Install_Run.bat b/Patch104pZH/MAKE_Install_Run.bat index 233890940..37dce1650 100644 --- a/Patch104pZH/MAKE_Install_Run.bat +++ b/Patch104pZH/MAKE_Install_Run.bat @@ -1,6 +1,47 @@ +@echo off +:: BatchGotAdmin +:------------------------------------- +:: --> Check for permissions +>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" + +:: --> If error flag set, we do not have admin. +if '%errorlevel%' NEQ '0' ( + echo Requesting administrative privileges... + goto UACPrompt +) else ( goto gotAdmin ) + +:UACPrompt + echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" + set params = %*:"="" + echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" + + "%temp%\getadmin.vbs" + del "%temp%\getadmin.vbs" + exit /B + +:gotAdmin + pushd "%CD%" + CD /D "%~dp0" +:-------------------------------------- +echo on + call MAKE_Install.bat +:: Rename files as per setup in SETUP_UserSettings.bat +for %%f in (%GameFilesToDisable%) do ( + if exist %GameRootDir%\%%f ( + ren %GameRootDir%\%%f %%f.PATCH104P + ) +) + set GameExeArgs0=%GameExeArgs:"=% ::Run game %GameRootDir%\%GameExeFile% %GameExeArgs0% + +:: Restore files as per setup in SETUP_UserSettings.bat +for %%f in (%GameFilesToDisable%) do ( + if exist %GameRootDir%\%%f.PATCH104P ( + ren %GameRootDir%\%%f.PATCH104P %%f + ) +) diff --git a/Patch104pZH/SETUP_UserSettings.bat.txt b/Patch104pZH/SETUP_UserSettings.bat.txt index d41415e80..40cb1604f 100644 --- a/Patch104pZH/SETUP_UserSettings.bat.txt +++ b/Patch104pZH/SETUP_UserSettings.bat.txt @@ -1,3 +1,5 @@ +@echo off + :: Copy this file, remove the .txt extension from the file name, and edit it depending on your requirements. :: Set game install root directory @@ -8,3 +10,26 @@ set GameExeFile="generals.exe" :: Set game launch command line arguments set GameExeArgs="-win -quickstart" + +:: Set files that should be voided (renamed) before launching generals.exe +set GameFilesToDisable= +set GameFilesToDisable=%GameFilesToDisable% "200_ControlBarObsEnglishZH.big" +set GameFilesToDisable=%GameFilesToDisable% "250_HideIP_WindowZH.big" +set GameFilesToDisable=%GameFilesToDisable% "251_HideMail_WindowZH.big" +set GameFilesToDisable=%GameFilesToDisable% "339_ControlBarProHideIpZH.big" +set GameFilesToDisable=%GameFilesToDisable% "339_ControlBarProHideMailZH.big" +set GameFilesToDisable=%GameFilesToDisable% "340_ControlBarPro1080ZH.big" +set GameFilesToDisable=%GameFilesToDisable% "340_ControlBarProZH.big" +set GameFilesToDisable=%GameFilesToDisable% "400_ControlBarHDBaseZH.big" +set GameFilesToDisable=%GameFilesToDisable% "400_ControlBarHDBrazilianZH.big" +set GameFilesToDisable=%GameFilesToDisable% "400_ControlBarHDChineseZH.big" +set GameFilesToDisable=%GameFilesToDisable% "400_ControlBarHDEnglishZH.big" +set GameFilesToDisable=%GameFilesToDisable% "400_ControlBarHDFrenchZH.big" +set GameFilesToDisable=%GameFilesToDisable% "400_ControlBarHDGermanZH.big" +set GameFilesToDisable=%GameFilesToDisable% "400_ControlBarHDItalianZH.big" +set GameFilesToDisable=%GameFilesToDisable% "400_ControlBarHDKoreanZH.big" +set GameFilesToDisable=%GameFilesToDisable% "400_ControlBarHDPolishZH.big" +set GameFilesToDisable=%GameFilesToDisable% "400_ControlBarHDSpanishZH.big" +set GameFilesToDisable=%GameFilesToDisable% "800_GermanUncutLiteZH.big" + +echo on