How to copy files from a machine in different domain through Task Scheduler in Windows
I had a requirement to copy files(build output files) from my remote build machine to a SharePoint Virtual Machine automatically . These two machines were in two different domains. To get this task done, I created a batch file which will copy the files from build machine to SharePoint Virtual Machine.
The batch file code is simple as shown below :
xcopy \\buildmachine\BuildDrops \\sharepointvm\BuildDrop\Packages /S
But the issue here is I had to provide my credential to access the build machine every time. I was not ready hard code my credentials in the batch file code(since the machine will be accessed by different resources). Then I thought why not use "Credential Manager" which is available in "Control Panel" in Windows Server 2008. Once my credentials are stored here then I need not provide credentials every time the Scheduler Task tries to copy the files from build machine.
The credentials can be stored in the "Credentials Manager" permanently using the below command :
net use \\buildmachine\BuildDrops /savecred
This will prompt for user name and password. On successfully validation the user name will be stored in the "Credentials Manager".