If the domains are trusted, why not just give domainA user permissions to domainB printer? That is the purpose of domain trusts. Then you should be able to just run the command you have posted.
I have probably misused the term “Trust relationship”.Domain B is accessible from Domain A , but not vice versa. Users & Computers are valid only in their corresponding domain.
Do you have an idea of how to send the proper credentials to the printer?
That still sounds like DomainA (user domain) trusts DomainB (resource\printer domain). This still means that DomainA credentials can be given to DomainB resources.
If you do want to connect with credentials, then you would need to use WScript.Network or net use, both outlined here:
What is the scope of this project? Are you implement for multiple hosts or just trying to find a solution for your local workstation on a one off basis?
If this is a one off, and the domains are not trusted, you can enter domain B in your stored creds. Then it should work.
If this is for multiple users in a multi domain environment, and domain b is there to provide printing solutions to domain a, I would suggest to do as Rob says and implement a trust.