0

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?

2
  • Have you tried running it with highest credentials? Commented Feb 18, 2020 at 21:30
  • @Davidw - Yes, in the elevated mode as administrator. No difference Commented Feb 18, 2020 at 22:19

1 Answer 1

1
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\"" 
5
  • Děkuji Josefe (Thank you, Josef) Commented Feb 19, 2020 at 13:07
  • What I am suppose to do to prevent to show a command prompt window when the scheduler runs the task? Currently it shows and immediately closes the command prompt window, which is unwanted and annoying. Please advise. Thanks. Commented Feb 19, 2020 at 14:54
  • How to prevent command window from appearing on scheduled tasks on Windows 10 works however I don't know how to do that using schtasks.exe tool without /XML xmlfile where xmlfile contains <LogonType>S4U</LogonType>. Commented Feb 19, 2020 at 20:27
  • I was looking for a direct way using command, not through the user interface. Commented Feb 19, 2020 at 21:30
  • Please cf Prevent Windows PowerShell console from flashing up. Commented Feb 20, 2020 at 0:30

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.