Windows Server 2008 R2 (fully patched)
I'm trying to run a scheduled task to move a specific type of files from C:\Windows\Temp to E:\Foo_blah_blah_blah_blah\Foo2 and for some reason am getting the following error:
Task Scheduler failed to start instance "{fe0f148a-cece-44a0-a4d1-914aaf21daa8}" of "\Move Temp Files" task for user "FOOBOX\Administrator". Additional Data: Error Value: 2147942402
Any idea why this is happening?
Additional details:
- The task is configured to run as an account that has authority to move the file.
- The task is configured to run whether user is logged on or not. It fails for both scenarios - same errors.
- The task is configured to run for the local OS (Windows Server 2008)
- The command is broken up into two parts. Program/script:
move
Add Arguments:C:\Windows\Temp\*.foo E:\Foo_blah_blah_blah_blah\Foo2\
If I run this same command move C:\Windows\Temp\*.foo E:\Foo_blah_blah_blah_blah\Foo2\
from the windows command prompt, it works fine.
What am I missing?
As Ryan Ries pointed out, 2147942402 translates to "File not Found" - which is a very appropriate response. Try and press Win+R, put in "move" and press enter - that's the interactive equivalent of what your task is failing to do.
The reason is that
MOVE
is not a program, but a native command incmd
.It should be:
Program:
"cmd.exe"
Arguments:
"/c move C:\Windows\Temp\*.foo E:\Foo_blah_blah_blah_blah\Foo2\"
The reason is: the Task is configured to be deleted when it is not scheduled to run again. This is configured in the Settings Tab. The deletion of the Task is done at the expiration time of the Trigger that fires the Task. If the expiration time of the trigger is exactly the same as the start time of the trigger it may (incidentally) happen that the Task is deleted a few seconds before its trigger fires. This causes the event 101 with reason code 2147942402. The solution is to set the expiration time of the trigger 1min later than the start time of the trigger.
with Powershell, specify full path in command, thus C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
The answer that Matthias posted helped me figure out my problem.
I had put the whole command line into the "Program" field, path and args all together; I hadn't noticed that there was a separate "Args" input field. When I split the arguments off and entered them separately, my scheduled task ran like a champ.
Diagnosis: The OS was looking for a program called
"C:\bin\someprog.BAT connect keep"
rather than looking for"C:\bin\someprog.BAT"
and invoking that with argumentsconnect keep
.My mistake, now fixed.
After going down several rabbit holes I found the issue was that Windows couldn't find powershell.exe (???). Putting the full path to powershell into the programme field solved it.
Maybe it's the problem of the blanks in the line of order example:
C:\Program Files\Wireshark\Wireshark.exe -i1 -k FAILS
"C:\Program Files\Wireshark\Wireshark.exe" -i1 -k OK