The Windows net use
command can do that.
- Microsoft docs (until they break all their URLs again): Net use | Microsoft Learn
So, something like this:
net use \\computer_name\share password /user:username
In some cases the username may need to include the computer/domain.