Task Scheduler Error – How to Fix Task Scheduler Error Value 2147942402

scheduled-tasktask-schedulerwindowswindows 10windows-command-prompt

I tried to schedule a task by

schtasks /create /tn Test /sc minute /mo 1 /tr "del /f \"%UserProfile%\path\file\""

…however the Scheduler always ends up with the following type of error:

Task Scheduler failed to launch action "del" in instance
"{a6c5962d-ed1e-4917-9d43-07525dd03218}" of task "\Test". Additional
Data: Error Value: 2147942402

The file in the path exists. I can run the same del command from console and it deletes the file successfully, but I cannot make it work with scheduled task.

What I am doing wrong?

Best Answer

where del
INFO: Could not find files for the given pattern(s).

Use

/TR "\"C:\Windows\System32\cmd.exe\" /C del /f \"%UserProfile%\path\file\""