Forum Discussion
Task Scheduler on Windows Server - 0x2 error
Event Viewer would tell you the most about what's going wrong. The Task Scheduler MMC makes the event log easier to navigate by filtering events under the defined job's History tab (which I suspect you already know but put here for the benefit of others.)
0x2 means "file not found", which is odd. Since %windir%\System32 is - at least by default - part of the system-wide PATH definition, there shouldn't be any issues finding "net" (or net.exe), but clearly you're running into issues finding whatever it is you're using for the
Have you tried specifying the full path to net.exe in the "program/script" section, as per the example below? (Forget about my argument and use your own - that's not really relevant.)
Incidentally, the working directory won't help you resolve path issues. It's relevance is a different topic altogether. "Run with highest privileges" is also irrelevant in this case. "File not found" is a very explicit kind of error.
In your case, you'd drop the "start tssdis" into "add arguments" - just as you described in your original post.
Cheers,
Lain
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).
- DavidYorkshireMay 25, 2022Iron Contributor
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