I know I'm kind of late on this thread. I was keeping the command below in a text file, copy paste into a cmd window for years and after reinstalling Windows 11 24H2 it stopped working. I tried all the solutions in this thread but with no luck. Just to realized that for some reasons the name of the actual file (file.db) was missing at the end of the command, resulting in a "Access is denied", that sent me on a while goose chase! Hope it helps someone!
adb exec-out run-as <package name> cat databases/file.db > C:\Users\<user>\Documents\_MyAndroid\Database\file.db