Skip to content

Commit

Permalink
Build: Install scripts will request admin privileges and patch unrela…
Browse files Browse the repository at this point in the history
…ted 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
  • Loading branch information
xezon authored Sep 4, 2021
1 parent 4b60183 commit a01a16a
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Patch104pZH/MAKE_Install.bat
Original file line number Diff line number Diff line change
@@ -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

Expand Down
41 changes: 41 additions & 0 deletions Patch104pZH/MAKE_Install_Run.bat
Original file line number Diff line number Diff line change
@@ -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
)
)
25 changes: 25 additions & 0 deletions Patch104pZH/SETUP_UserSettings.bat.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

0 comments on commit a01a16a

Please sign in to comment.