Forum Discussion
Task Scheduler on Windows Server - 0x2 error
OK, looking at the task scheduler logs in event viewer (with the task set to run the batch file, as that is how it used to work), I see the following:
- Task Scheduler launched "{removed}" instance of task "\StartTssdis" due to a time trigger condition.
- Task Scheduler launch task "\StartTssdis" , instance "C:\Windows\SYSTEM32\cmd.exe" with process ID 1060.
- Task Scheduler started "{removed}" instance of the "\StartTssdis" task for user "removed".
- Task Scheduler launched action "C:\Windows\SYSTEM32\cmd.exe" in instance "{removed}" of task "\StartTssdis".
- Task Scheduler successfully completed task "\StartTssdis" , instance "{removed}" , action "C:\Windows\SYSTEM32\cmd.exe" with return code 2147942402.
- Task Scheduler successfully finished "{removed}" instance of the "\StartTssdis" task for user "removed".
Shows in task scheduler as a 0x2, so failed for no clear reason (the batch file it is calling definitely exists).
If I change the task as follows:
it also fails with a 0x2. In event viewer:
- Task Scheduler launched "{removed}" instance of task "\StartTssdis" due to a time trigger condition.
- Task Scheduler launch task "\StartTssdis" , instance "%windir%\system32\net.exe" with process ID 11736.
- Task Scheduler started "{removed}" instance of the "\StartTssdis" task for user "removed".
- Task Scheduler launched action "%windir%\system32\net.exe" in instance "{removed}" of task "\StartTssdis".
- Task Scheduler successfully completed task "\StartTssdis" , instance "{removed}" , action "%windir%\system32\net.exe" with return code 2147942402.
- Task Scheduler successfully finished "{removed}" instance of the "\StartTssdis" task for user "removed".
So I'm really not seeing what's causing this. Looking online, it's clear that the 0x2 error despite the file definitely existing is a long-standing common issue.
- LainRobertsonMay 25, 2022Silver Contributor
This is where monitoring with Process Monitor (procmon from SysInternals - now operated by Microsoft) would provide real clarity.
But I have seen a similar, very rare issue before albeit in a different context to what you're doing with net.exe, so I'll throw this out there as an option to try (in the Hail Mary category.)
Try creating the following two directories:
- C:\windows\system32\config\systemprofile\desktop
- C:\windows\syswow64\config\systemprofile\desktop
You should create these from an administrative command prompt to avoid the additional permissions Windows Explorer adds, but to each their own.
At the end of the day, a file or directory is definitely missing, it's just a case of determining what it is. If you are game to give it a try, ProcMon (mentioned above) will answer that question for you.
Cheers,
Lain
- DavidYorkshireMay 26, 2022Iron ContributorCreated the first of those directories, from an administrative command prompt. Second one already existed.
Doesn't seem to have made any difference - task is still giving a 0x2.
Thanks- LainRobertsonMay 27, 2022Silver Contributor
Yeah, fair enough - it was only an educated guess at best. Task Scheduler could be looking for anything (though probably something related to creating the session environment passed into the CreateProcess call.)
Within Process Monitor, you can configure a filter like the one shown below to find what is missing. There's not much value in me making further guesses on what the missing component might be.
Ideally, you want to:
- Set up the filter first while paused;
- Make sure the history has been cleared;
- Start the capture;
- Start the scheduled task;
- Stop the trace once complete (should only take seconds to fail);
- Check the results.
The only display filters you'd want to check out are the files and registry filters, and even then, possibly just one at a time if the number of returned rows is significant.
Process Monitor filter
Example results, also showing the display filters
Cheers,
Lain