Reputation: 75
I have about 20 scheduled tasks on Windows Server 2008 R2 Standard. They have been working well for a couple weeks, then all of a sudden this weekend they all stopped. The tasks are all .bat files and .exe files, each working fine by clicking in explorer or running from cmd. I created a new task to run a .bat from the c: drive, and another to simply display a message, and always get the Last Run Result "The system cannot find the file specified. (0x8007002)" for all tasks.
Here is a summary of the different fixes suggested:
-Make sure user that runs the task has permission to use all files -All networked drives in .bat files should be referenced with full domain, not local drive letter
-Uncheck "Run with highest privileges" in the General tab of properties
-remove file path from program name in the action, and enter path into Start In
-remove quotes from Start in
-Unclick "start the task only if the computer is on AC power" in the conditions tab because some services can trick the server into thinking it has a battery
-Unclick "Stop if the computer ceases to be idle" on the conditions tab
-Make sure user is in Local Security Policy > Local Policies > User Rights Assignment > Log on as a batch job
After trying all these, i still get "cannot find the file not specified" for run result and Task Start Failed for Task Category with Error Value 2147942402
Anybody have another suggestion?? If nothing else hopefully this is a good summary of things to try for other issues.
Upvotes: 4
Views: 14648
Reputation: 28869
tl;dr: If you're getting this error while running as a service account, then don't set the setting: "If the task is already running..." to "Stop the existing instance". Use any of the other 3 options.
I was struggling with this error too, and my solution ended up being a rabbit hole with a surprising cause, so I thought I'd share in case it helps someone else.
In my particular case I have Scheduled Tasks that run as a service account. To modify the task I make the change, save the runas user as me, and then use the command prompt to change the runas user to a service account. When the user is me, the task runs fine, but as soon as I change the runas user to the service account I was getting the same error:
"The system cannot find the file specified. (0x8007002)"
The way I troubleshot it was by exporting the xml from one that worked as a service account and one that didn't, then comparing them and doing small edits to the xml and importing it back in until I identified the single setting that was causing the problem. It turned out to be this one under <Settings>
:
<MultipleInstancesPolicy>StopExisting</MultipleInstancesPolicy>
If I selected any of the other 3 options the problem goes away and the Service Account can run the task without any issues:
As for why this happens, I believe it's simply a bug in the Windows GUI that the "Stop the existing instance" choice may not actually be supported. This appears to be confirmed by this answer to a different question.
Upvotes: 0
Reputation: 21
Try using:
pushd \\machine\share
within a batch file of your scheduled task. Network shared drives are only available from a user-run environment. "pushd" will allow it to be run in the context of the script.
When you're done use:
popd \\machine\share
to unmap the drive.
Reference: http://www.adrianbanks.co.uk/?p=41
Upvotes: 2