0

I am trying to copy the content from a mounted drive to this computer. The following command works perfect when I run it directly on cmd. But when I make a bat file and run it through windows Scheduled Task, it says the drive is invalid. Drive Y is actually the drive of another computer on the network and is mounted to this computer to share the content.

C:\WINDOWS\system32>xcopy /s /Y Y:\Database\* D:\Backups\TaskMania\Database\ 
Invalid drive specification
0 File(s) copied

If the drive Y is invalid, how is it working directly though cmd then?

I have also set the Scheduled Task to run with Administrator privileges.

enter image description here

Adil Malik
  • 6,279
  • 7
  • 48
  • 77
  • 2
    Your scheduled task runs under another user (SYSTEM in this case), where the drive is NOT connected. – Stephan Jan 24 '22 at 17:20
  • This would be a good place to use UNC names. Find out where "Y:" exists using `Get-PSDrive | Where-Object { $_.Provider -match 'FileSystem' } | Select-Object -Property Name,DisplayRoot` or the `NET USE` command. – lit Jan 24 '22 at 17:27
  • @Stephan The scheduled task is being run on `Administrator` user account. Isn't it? The drive is mounted on `Administrator`. – Adil Malik Jan 24 '22 at 17:42

0 Answers0