I'm looking for a way to copy files over to/from remote Windows hosts, and need to provide domain user credentials as part of the process, similar to the way psexec does.
I know I can use net use to map the target directory to a drive letter and use xcopy, and I know psexec can upload files to be executed on the remote machine and then delete them, but I'm looking for a way to distribute files to remote hosts that will not be as awkward to use as net use and xcopy.
4 Answers
XCopy supports UNC paths.
C:\>xcopy \\computer1\source\*.* \\Computer2\target
C:\>xcopy \\computer1\source\FakeFileNAme.txt C:\I would imagine with the use of RunAs you should be able to feed it whichever credentials you'd like.
HTH
5You can use robocopy. just open a command window and type robocopy /? to see available options.
Not exactly a "small utility", but the pywin32 package of Python for Windows has win32net and win32wnet modules that could be helpful with scripting credentials and such.
Since this question and answers, Powershell now supports remote copy.
See the documentation for Copy-Item
You may also need to Enable PSRemoting (depending on your target machine)
1Example 5: Copy a file to a remote computer
$Session = New-PSSession -ComputerName "Server01" -Credential "Contoso\PattiFul" Copy-Item "D:\Folder001\test.log" -Destination "C:\Folder001_Copy\" -ToSession $Session