system() is the right function; it should work fine also inside ~/.vimrc, but is best avoided as each external command delays Vim's startup and makes the user wait.
Ideally, you'll be able to only invoke the external command once it's required for a user interaction (i.e. lazily) - and then cache the information in case it's needed again.
If you absolutely ...
Ok, my bad. Turns out the path should really be C:\Windows\Sysnative\wsl.exe, as mentioned in the linked question. I changed it to System32 because I couldn't find the Sysnative folder under C:\Windows.
Apparently the Sysnative folder is kind of a virtual folder which exists only from the perspective of 32-bit programs.
More info can be found here: