Block a program launched from batch file from launching another program

I am trying to work around a limitation. I'll give the full context, just for completeness.

In Unreal Engine, each Unreal project (a .uproject file) is associated with a specific version or a specific installation of the engine/editor. When launching the project by double-clicking it, it runs:

UnrealVersionSelector.exe /editor "C:\path\to\myproject.uproject"

Which in turn launches the associated engine editor. UnrealVersionSelector is in charge of parsing the .uproject file, finding the correct engine, and launching the editor.

What I need in my batch file is just the location of the engine. I want to run some other utility within that folder. Unfortunately, there is no option to just print the location of the engine. UnrealVersionSelector's source code is public and can be found here: https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Source/Programs/UnrealVersionSelector/Private/UnrealVersionSelector.cpp

My current plan: make the batch file launch UnrealVersionSelector in a special way that blocks it from actually launching the editor - then use the path of the failed editor launch to get the information I want.

Is this possible from a batch file?

Obviously I'm all ears for a better approach or something obvious that I'm missing.


Solution 1:

The engine is stored in the field "Engine Association" in the project file. If it is not an engine number, it can be a GUID for the engine build.

There is a "lookup table" in the registry under HKEY_CURRENT_USER/Software/Epic Games/Unreal Engine/Builds so you can line up a GUID with an engine build.

So if you can extract the GUID (see for example: https://stackoverflow.com/questions/24943001/extracting-text-from-xml-file-via-batch-file), then do a reg query, you probably have what you need.