net use Z: \\ServerName\ShareName /user:Domain\UserName *
For decades, NET USE has been the standard for connecting to and disconnecting from network resources. It’s part of the legacy Net commands, but don't let its age fool you—it's still the most dependable tool for the job. map drive command line
To disconnect and return to the original drive: map drive command line
:
net use