Zeev Posted October 10, 2020 Posted October 10, 2020 (edited) Hi, As a lazy person and one that likes automation, I have decided to write a batch script to automate the process of installation of new content like single player missions and campaigns. TL;DR: You save the script, you download any archive mission from this forum, you drop the zip on the script, then follow the instructions. How does it work? You save the script batch file anywhere in your computer (e.g "Desktop", "c:\temp" etc) You download any user uploaded mission zip file (tested only zip, but should work with rars as well) Drag and Drop the zip file into the script. After a while, it should tell you: A. Your game location (it automatically detects your game folder path if the game was bought from this store. Steam version is not supported) B. 7-Zip location (mandatory for script to work) C. Whether it detected its a "Mission" or a "Campaign" D. Follow on screen menu to either: (1) List archive content to be sure what you are unzipping and doing (2) Get details on archive (3) Extract the file in following i. If detected as a Mission or Campaign, just extract ii. If the archive was not detected, you have several options, either to unzip as is or create new folder and select where to unzip (under \data\Missions or \data\Campaigns) Algorithm (How it detects the content) Please Note: Its very important to read the algorithm and try to understand how it works before using the script on your own. The method I am using is simple. Go through archive file folder tree. Have it detected \data\Missions? Its a mission archive file and should be extracted "as is" (script menu option) Have it detected \data\Campaigns? Its a campaign archive file and should be extracted "as is" (script menu option) Script did not detect archive type? Do not worry, it will let you choose to list the archive file to see for yourself the folder tree and determine by yourself whether its a mission or a campaign, then follow the script instructions to extract it either to missions or campaigns and whether to make a new folder or not. Requirements You need the following in order for script to work: Important: 7-Zip installed. Its mandatory because it allows the script to dive into the archive and get its folder\file structure to determine the content type Powershell (available in almost any modern operation system since Windows 7) Disclaimer Please note! Be sure to use the "List archive" before you do any extraction action, I do not take any responsibility for your actions. Bugs? I am sure there are. Please let me know if this script works for you. It took me a day to write and test it on my environment, but since there are many user environments, I am sure there will be issues. So if any, send me feedback here or PM. Download ContentInstaller.zip Full script (so you are sure its safe to use) Please note! In case you do not want to download the above attached file (for any security reason..) you can simply read the code below, copy everything and save to text file on your computer, then rename it to "something.cmd" and drop the archive on it. @echo off REM Define Variables SET runningDir = %CD% REM Get the IL2 Great Battles application path FOR /F "usebackq tokens=3*" %%A IN (`reg query "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{66F649A9-0FA2-487E-BC0D-894BD7E89D5E}_is1" /v InstallLocation`) DO ( set appdir=%%A %%B ) ECHO Great Battles application path: %appdir% REM Get the 7-zip application path FOR /F "usebackq tokens=3*" %%A IN (`reg query "HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip" /v Path`) DO ( set zdir=%%A %%B ) ECHO 7-Zip application path: %zdir% REM Get the argument ECHO Argument is: %1 IF [%1] == [] GOTO EmptyArgument set zipcommand="%zdir%\7z.exe" l -r %1 %zipcommand% > zipoutput.txt REM Determine zip file content logic findstr /c:" data\Campaigns" "zipoutput.txt" >nul 2>&1 if errorlevel 1 (ECHO .) ELSE (GOTO Campaigns) findstr /c:" data\Missions" "zipoutput.txt" >nul 2>&1 if errorlevel 1 (ECHO .) ELSE (GOTO Missions) GOTO MenuIfNotFound :Campaigns CALL:ECHOGREEN "Search Result: Campaign files type found. What do you want to do?" GOTO MenuIfFound :Missions CALL:ECHOGREEN "Search Result: Mission files type found. What do you want to do?" GOTO MenuIfFound :MenuIfFound ECHO 1 - Extract archive content to game dir ECHO 2 - List archive content ECHO 3 - Show archive details set /P answer=Enter your choise (number): IF "%answer%" == "1" GOTO ExtractArchiveIfFound IF "%answer%" == "2" GOTO ListArchiveIfFound IF "%answer%" == "3" GOTO ArchiveDetailsIfFound GOTO Skip :MenuIfNotFound REM CLS CALL:ECHOORANGE "Cannot determine archive content type. What do you want to do?" ECHO 1 - Extract to data\Missions ECHO 2 - Extract to data\Campaigns ECHO 3 - List archive content ECHO 4 - Show archive details set /P answer=Enter your choise (number): IF "%answer%" == "1" GOTO ExtractToDataMissions IF "%answer%" == "2" GOTO ExtractToDataCampaigns IF "%answer%" == "3" GOTO ListArchiveIfNotFound IF "%answer%" == "4" GOTO ArchiveDetailsIfNotFound GOTO Skip :ListArchiveIfFound type zipoutput.txt GOTO MenuIfFound :ArchiveDetailsIfFound for /f "delims=" %%x in (zipoutput.txt) do set listContent=%%x echo %listContent% GOTO MenuIfFound :ListArchiveIfNotFound type zipoutput.txt GOTO MenuIfNotFound :ArchiveDetailsIfNotFound for /f "delims=" %%x in (zipoutput.txt) do set listContent=%%x echo %listContent% GOTO MenuIfNotFound :ExtractArchiveIfFound ECHO Extracting archive content, please wait... "%zdir%\7z" x %1 -aoa -o"%appdir%" GOTO Skip :ExtractToDataMissions ECHO Please choose the following options ECHO 1 - Extract as is into \data\Missions ECHO 2 - Create additional folder under \data\Missions\ then extract files there set /P answer=Enter your choise (number): IF "%answer%" == "1" GOTO ExtractAsIsMissions IF "%answer%" == "2" GOTO ExtractMissionsCustom :ExtractToDataCampaigns ECHO 1 - Extract as is into \data\Campaigns ECHO 2 - Create additional folder under \data\Campaigns\ then extract files there set /P answer=Enter your choise (number): IF "%answer%" == "1" GOTO ExtractAsIsCampaigns IF "%answer%" == "2" GOTO ExtractCampaignsCustom :ExtractAsIsMissions ECHO Extracting archive content, please wait... "%zdir%\7z" x %1 -aoa -o"%appdir%\data\Missions" GOTO Skip :ExtractAsIsCampaigns: ECHO Extracting archive content, please wait... "%zdir%\7z" x %1 -aoa -o"%appdir%\data\Campaigns" GOTO Skip :ExtractMissionsCustom set /P folder=Please enter folder name to be extracted to under \data\Missions\ mkdir "%appdir%\data\Missions\%folder%" set /p answer=Do you really want to extract archive content under %appdir%\data\Missions\%folder% (y/n) IF %answer% == "n" GOTO Skip "%zdir%\7z" x %1 -aoa -o"%appdir%\data\Missions\%folder%" GOTO Skip :ExtractCampaignsCustom set /P folder=Please enter folder name to be extracted to under \data\Campaigns\ mkdir "%appdir%\data\Campaigns\%folder%" set /p answer=Do you really want to extract archive content under %appdir%\data\Campaigns\%folder% (y/n) IF %answer% == "n" GOTO Skip "%zdir%\7z" x %1 -aoa -o"%appdir%\data\Campaigns\%folder%" GOTO Skip :EmptyArgument ECHO Archive path is empty. Have you dropped the archive into this script? ECHO Please drag and drop archive file into this script file. :ECHOGREEN %Windir%\System32\WindowsPowerShell\v1.0\Powershell.exe write-host -foregroundcolor Green %1 goto:eof :ECHOORANGE %Windir%\System32\WindowsPowerShell\v1.0\Powershell.exe write-host -foregroundcolor Yellow %1 goto:eof :Skip pause Edited October 10, 2020 by Zeev 1 2
Recommended Posts