Tuesday, November 20, 2012

Silly Batch Games

As it turns out, under Windows 7 you cannot copy to or from a mapped network drive letter in a batch file or script running as admin or running via scheduler.  From the command line it works fine, from a batch file run at the commant line it works fine.

Run it as admin or through the scheduler, and it fails.

The secret is to not use the mapped drive letter, but instead to use the full server path, such as \\servername\path\filename.ext in the batch file and it works fine.

so this will fail :
copy c:\tmp\filename.txt w:\tmp\filename.txt

where w: is a drive letter mapped to a network share on \\fileserver

but this will work:

copy c:\tmp\filename.txt \\fileserver\tmp\filename.txt