Python looks for build_flags.py in wrong directory

I’m trying to build the Marlin firmware using Auto Build Marlin and PlatformIO under VSCode.
I have all the build files in D:\MFW\Marlin-bugfix-2.0.x. When I try to build, whether from Auto Build Marlin or directly from PlatformIO I get the following error.

python: can’t open file ‘D:\Marlin\src\HAL\STM32F1\build_flags.py’: [Errno 2] No such file or directory

It should, of course, be looking for
D:\MFW\Marlin-bugfix-2.0.x\Marlin\src\HAL\STM32F1\build_flags.py

Is there some way to direct python to only look under the build directory?
Any help gratefully received.

Please report build failures of Marlin to the Marlin project. https://github.com/MarlinFirmware/Marlin/.

I have reported this to the Marlin project but suspect my problem (or at least the solution) is with PlatformIO.
Investigation reveals that when any of the build tools are called the Current Working Directory(CWD) has been set to D:\ and as all the file references are relative to the project directory, D:\MFW\Marlin-bugfix-2.0.x, the build tools cannot find the files they’re supposed to act on.
Unfortunately I’m not yet very familiar with PlatformIO but I imagine there must be some way to capture the CWD at the start and to enforce it throughout.
Or alternatively, if someone could suggest why the CWD on my machine changes (as it doesn’t seem to on anyone else’s) that would also be much appreciated.

Mea culpa, mea culpa, mea maxima culpa.
I’ve worked out what’s happening.
When I’m working in a command console I like to have certain Doskey macros enabled and some other bits of environment.
I arrange this by naming a batch file in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor\AutoRun.
A while ago I set this batch file to set the directory to D:\ and that’s what’s been happening.
I’ll post this here as a warning to others.