Task Scheduler and Mapped Drive Invalid Disk Specification

network-sharestask scheduler

I have a task in Task Scheduler to run a batch file that resides on a local hard drive.

The batch file simply runs XCopy to copy files from a mapped drive to a folder on the local drive.

When the batch file is run from the command line, it functions perfectly.

When it's run from Task Scheduler, the XCopy command displays the error:

Invalid drive specification

If it matters, the drive is a NAS and is mapped to the computer using local credentials from the NAS (there is no active directory in the network).

Best Answer

I've seen this behavior before when trying to backup to a mapped NAS. I don't know why, but it needs a "nudge" to remember that X: drive is mapped to \myserver\myfolder.

Manually, this can be solved by accessing the target folder. Once you "touch" X:, Windows "remembers" it's there. Programmatically (i.e. from batch), you can either try accessing the mapped folder, or maybe even remapping it (using the net command) in the batch, before the XCopy command.

Related Question