I have a Task Scheduler job to run Robocopy for backing up local files to a network share. I have to use domain credentials to access the network share but the local computer is not on the domain, and the job is run as a local admin. This solution of temporarily mapping and unmapping the network share works but it leaves my password exposed in plain text for anybody who looks at the Task Scheduler job actions. I would prefer to map the network drive normally on a semi-permanent basis so the Task Scheduler job just has to run Robocopy and refer to the appropriate drive letter. However I always get the error "The system cannot find the path specified." in the Robocopy log when running this from Task Scheduler, even though the command works fine from an elevated command prompt (job is set to run with highest privileges). Also note I have done this registry tweak to access mapped drives from an elevated command prompt.
EDIT: To clarify, logged in as the local admin, I launch Windows Explorer as administrator. I map the network share to drive letter Y. I launch the command prompt as administrator and run
C:\Windows\System32\Robocopy.exe C:\temp Y:\temp
Works fine. I create a Task Scheduler job to run the exact same command, whether user is logged in or not, with highest privileges. I run it and get an error. I write to a log and get
ERROR 3 (0x00000003) Getting File System Type of Destination Y:\temp\ The system cannot find the path specified.
ERROR 3 (0x00000003) Creating Destination Directory Y:\temp\ The system cannot find the path specified.