on-internet
← Community

Command-line file copy to remote share with different login

Stack Overflow ·

I want to copy a file to a remote location. This task will run from SQL Server (Agent) scheduler, and thus the COPY will run under the SQL Service account, and I don't want to create matching credentials on the remote machine. Only way I figured was: NET USE X: \RemoteServer\RemoteShare ThePassword /USER:RemoteUserID then I can run a command to copy to X: However, X: cannot be relied upon to be persistent, so I came up with: NET USE X: /DELETE NET USE X: \\RemoteServer\RemoteShare ThePassword /USER:RemoteUserID COPY MyFile X: NET USE X: /DELETE and ignored the initial delete if X: was not alre

Comments

Sign in or sign up to comment and upvote.

No comments yet.