2

I write a bat file to copy .zip to another location. The file copy from localhost to another pc.(the disc is defined as R)

I wrote this commands:

@echo off 
move /Y "C:\xx\yy.zip" R:\xx
cd /D R:\xx\
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c%%a%%b)
For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b)
ren "yy.zip" "yy%mydate%_%mytime%.zip"

The problem is in the task scheduler is I set folder location,and select bat file, and ** I set run whether user log on or not** and select high privileges then it gives 0X1 error. But if I deselect whether user log on or not tick it works. But I need to tick it

How can I solve this?

thanks in advance

CompEng
  • 7,161
  • 16
  • 68
  • 122
  • 1
    I think the problem is that you only have the rights to write to the remote drive when a user is logged in that also has ther rights to do so. You should try to add the COMPUTER you are running your scheduled task on to the trusted list of the machine you want to copy your files to. – MichaelS Nov 26 '14 at 09:18
  • 1
    Just to make sure what I mean by "trusted": add the machine with the scheduled task to the administrator group of the remote pc. I'm pretty sure this should work. – MichaelS Nov 26 '14 at 09:35
  • I'm glad I was able to help. I'll move the comments to "Answer" :) – MichaelS Nov 26 '14 at 10:02
  • See the possible solutions in [this answer](http://stackoverflow.com/a/34362341/4543366) – full_prog_full Dec 18 '15 at 19:11

1 Answers1

3

I think the problem is that you only have the rights to write to the remote drive when a user is logged in that also has ther rights to do so. You should add the machine with the scheduled task to the administrator group of the remote pc.

MichaelS
  • 5,941
  • 6
  • 31
  • 46