Windows – Scheduled task works on a mapped drive when configured for Windows XP mode, but not for Windows 7

mapped-drivescheduled-taskswindows 7windows task scheduler

There is a Windows 7 PC with a scheduled task. The only thing it does is running a VBS file located on a mapped drive that points to a network share:

M:\Folder\Script.vbs

where M: is the mapped drive.

The task is set to Run whether user is logged in or not, and it has saved credentials for user who has access to that folder.

Now, if I select this in the dropdown:

enter image description here

then the task works. However if I select that:

enter image description here

then it fails with code 8007010B (which, as I understand it, is "Directory name is invalid"). It fails whether or not someone is logged in, and regardless of what triggered the task (the schedule or the user who Run it manually). It also fails if I log in to the computer as the user under which the task is supposed to run and Run it manually.

When I'm logged in as the user under which the task runs, I have access to the mapped drive and can run the script with Explorer no problem.

Apparently there is some compatibilty shim kicking in, but which one? And what do I do to make it work when 'configured for Windows 7', which should be the native mode for the computer?

I would just leave it as is, but if someone mistakenly 'upgrades' the task to the Windows 7 mode, there is no way back: the Windows XP option is then removed from the menu for that task. To have it back, one needs to export the task as XML, delete it and reimport.

Best Answer

When the task runs, the M: drive map doesn't exist in the context of the user/session the task is being run as.

Either reference the network location by UNC, or modify the task's script to map M: to the path before performing the rest of its work.