Thanks a lot Johannes!
I think I’ve now sorted the issue out, so providing more details in the (I think unlikely) event that anyone else runs into it. The short story seems to be that I have picked up multiple corrupt dynare installation files (I downloaded a bunch of them at the same time in 2022). As in, deleting and reinstalling dynare 4.6.4 and then 5.1 now allows me to run everything without issues…
Below is the long story in case anyone finds the version above suspicious / thinks I’ve gone nuts 
Starting with your question, Johannes: I’m on Windows 11 Pro, which is showing as up to date in windows update:
I do have admin rights and I don’t think there is anything funny with the location (my only suspicion was
dropbox, but it was paused, and I’ve replicated all the errors in a different directory not linked to
dropbox).
For reference, here’s a screenshot with more Matlab details and also the path settings:
So, first of all, here’s a replication of the error in
dynare 5.1:
With the same command running ok under
dynare 5.2:
For the avoidance of doubt, I also tried removing references to all other dynare versions from the path but that didn’t do the trick…
I then debugged 5.1 and 5.2 when running dynare on Test.mod. While the error is linked to line 269, the devil seems to be in line 243:
[status, result] = system(command);
The contents of command when running 5.1 are
'"C:\dynare\5.1\matlab\..\preprocessor\dynare-preprocessor" Test.mod mexext=mexw64 "matlabroot=C:\Program Files\Matlab\R2021a"'
In 5.2 it looks literally identical, except for 5.1 being replaced by 5.2, i.e., I get:
'"C:\dynare\5.2\matlab\..\preprocessor\dynare-preprocessor" Test.mod mexext=mexw64 "matlabroot=C:\Program Files\Matlab\R2021a"'
Inspecting the paths revealed that the dynare 5.1 installation didn’t have a
C:\dynare\5.1\preprocessor
folder, which was the source of the error. Question I asked myself being, why was dynare 5.1 trying to run something from a non-existent folder (I ran a stock installation)?
I checked and the same thing happened with version 4.6.4, where the command (this time in line 249) evaluated to:
'"C:\dynare\4.6.4\matlab\preprocessor64\dynare_m" Test.mod mexext=mexw64 "matlabroot=C:\Program Files\Matlab\R2021a"'
So the path was different, but the common issue was that the 4.6.4 installation didn’t have a
\matlab\preprocessor64
subfolder.
This is precisely what led me to wonder whether the dynare installations hadn’t gone corrupt, somehow. After reinstalling, I now do have a preprocessor64 subfolder of Matlab in 4.6.4, which is why things work ok. And the C:\dynare\5.1\preprocessor
also appeared after I reinstalled 5.1.
So ok, I may have accidentally and inadvertently deleted multiple preprocessor directories, but I like the corrupt installation files theory more (I was installing on the 2nd of October 2022 around 3:30pm so that’s where I’d pinpoint the issue to). In any case, everything working now, so can’t ask for more 
Thanks again for taking the time to read and help, Johannes - always much appreciated!
Pawel
ps. Obviously, open to dissenting views on what was going on…