0

I have a .bat that copies files from source to destination. The source is the local joined server, the destination is a non-joined computer on the network. I need to run this .bat with task scheduler. What user can have privileges on the destination folder? On task scheduler I can only set local or domain users. The syntax of the bat is like the following:

robocopy "C:\temp\test.txt" "\\192.168.0.1\c$\temp"
maurice
  • 51
  • 2
  • 6

4 Answers4

1

Since this question has a lot of hits from search engines I though it will useful to add another method that works well (mentioned in this reply to a similar question):

You can add the credentials to a user profile in Windows using the Credential Manager found in the Windows control panel.

  1. Login under the user that will be running a Scheduled Task
  2. Open Credential Manager
  3. Click "Add A Windows Credential"
  4. Populate the "internet or network address" field with the server name
  5. Populate the "User Name" (include domain where required, i.e. MyDomain\MyUser)
  6. Populate the "Password"
  7. Click OK

Your scheduled task will now automatically use the credentials saved in the Credential Manager for the specified host.

Note that if user password changes you would need to update that in the Credentials Manager.

And a picture that worth a thousand words: Windows Credential Manager in action

Rod
  • 111
  • 3
0

Because the destination machine is not joined, it is impossible to actually have your task running on your source host as a user from the destination host. The only way it might work is via pass-through authentication.

That is, create a user with the same username and password on both source and destination hosts. Then configure your task to run as that local user from the source host. Because the credentials are the same in both locations, Windows may be able to pass-through the authentication request to the destination host and just work because the credentials are the same.

I've never done this in the context of a scheduled task, but it works fairly reliably for interactive type stuff. You may run into some network UAC limitations depending on the OS versions though.

Ryan Bolger
  • 16,472
  • 3
  • 40
  • 59
0

Net Use should work for this:

Map a drive letter with net use, then use robocopy to copy to the drive letter. Wrap it all up in a bat script, then schedule the bat script.

net use x: \\servername\sharename /user:username password

For username, put LocalMachineName\username

At the end of your bat script, remove the drive mapping: net use x: /DELETE

Dre
  • 1,375
  • 6
  • 12
0

Why not try using "runas" in the batch file and for the username make sure you use MACHINENAME\username where MACHINENAME is the name of the non-domain joined computer.

The other problem I see is your syntax for robocopy is wrong. If you are only copying one file you might only need to use copy. If you want to use robocopy, please see the correct syntax below.

Then schedule the batch file to run on the domain joined computer.

runas /user:MACHINENAME\username robocopy "C:\temp\ \\192.168.0.1\c$\temp test.txt"

robocopy transfer file and not folder

https://stackoverflow.com/questions/1030739/how-can-i-copy-network-files-using-robocopy

user5870571
  • 2,900
  • 2
  • 11
  • 33