I have spent hours struggling with this nonsense. Short answer for me was to install vim: https://www.vim.org/download.php on Windows and then to run the following two commands:

set EDITOR="vim"
rails credentials:edit

I tried to do it with Visual Studio Code and Notepad but the issue for me was that the configuration file was not saved after VS Code or Notepad was closed. It looks like Ruby on Rails, at least on my side, expected the editor to run in the same terminal!

Anyways I hope that this has helped you edit credentials on Windows.