Why does my Task Scheduler task fail with error 2147942667?
Asked Answered
T

5

171

I have scheduled a task to lauch a batch file. When I run the task with the option

Run only when user is logged on

everything works fine.

I want to run this task in the background, hence I am running it using the option

Run whether user is logged on or not.

Now when I run the task under that parameter, it is not working. I get the following 2 errors:

  • Task Scheduler failed to launch action "C:\Windows\SYSTEM32\cmd.exe" in instance "{2a7cc950-fad9-4633-9701-af75a0fd220d}" of task "\stmm\Daemon". Additional Data: Error Value: 2147942667.
  • Task Scheduler failed to start instance "{2a7cc950-fad9-4633-9701-af75a0fd220d}" of "\stmm\Daemon" task for user "GBLADHEDANI\N011940" . Additional Data: Error Value: 2147942667.

What is Error Value: 2147942667? How can I resolve this errors?

Talky answered 29/11, 2012 at 4:40 Comment(6)
Convert the error code to hex to get 0x8007010B. The 7 makes it a Windows error. Which makes 010B error code 267. "The directory name is invalid". Sure, that happens.Rotatory
FWIW I found the main Task Scheduler UI had the task with a 'Last Run Result' or similar column, showing a readable 'The directory name is invalid' error message. The fix in our situation was the answer from jp2code below about removing quotes from Start In folder, because I'd copied it from the quoted Command to run.Bodwell
So my issue that resulted in 2147942667 turned out to be due to a mapped drive. When I set the "Program/script" and "Start in" paths to use the full UNC the job ran successfully.Bowie
To tie into @HansPassant's excellent comment: learn.microsoft.com/en-us/windows/win32/debug/…Hydrodynamic
@Mark Berry learn.microsoft.com/en-us/windows/win32/com/…Statvolt
From .NET, there is a static method GetExceptionForHR, but you must pass it a signed 32-bit integer. For example, if you open PowerShell and type [System.Runtime.InteropServices.Marshal]::GetExceptionForHR(0x8007010B) it will show you: The directory name is invalid. (Exception from HRESULT: 0x8007010B)Mattingly
C
342

To get the relevant error message:

  1. Convert 2147942667 to hex: 8007010B
  2. Take last 4 digits (010B) and convert to decimal: 267
  3. In a Command Prompt, run net helpmsg 267
  4. Result: "The directory name is invalid."

Command Prompt Window

The solution for me was that I had quotes in the "Start In" field. I found this information in Microsoft KB Article 2452723, Windows Vista onward scheduled tasks fail to run if the path in "Start in (Optional)" field has quotes.

Basically, edit your scheduled task and take the quotes out of the "Start In" field:

  1. Open your Scheduled Task
  2. Switch to "Actions" tab
  3. Open your Action
  4. Remove Quotes (") from the field "Start in (optional)"
  5. Save and close all open dialogs

Edit Action Dialog Box

You should also check for other causes of the error, like not having permission to access the directory, or using a mapped drive letter which is only available during certain login sessions.

Cavite answered 14/1, 2013 at 20:28 Comment(3)
For what it's worth I'm getting this error but my Start in folder setting has no quotes, rather the path that was referenced didn't exist.Fulmer
In my case under Server 2012 R2, "Start in" was blank, but the script I was running expected to be in a certain path. I updated the script so that it does not rely on being in a specific directory (adding explicit paths to commands in the script). After that, the scheduled task worked.Disembarrass
In my case, "Start in" had no quotes but I still got the message. Turns out I was running the command as an admin user on a folder belonging to a standard user. Not exactly sure why this was not allowed but it works once I moved the program to D:\Karyn
S
13

For me it was the "Start In" - I copied the values from an older server, and updated the path to the new .exe location, but I forgot to update the "start in" location - if it doesn't exist, you get this error too

Quoting @hans-passant 's comment from above, because it is valuable to debugging this issue:

Convert the error code to hex to get 0x8007010B. The 7 makes it a Windows error. Which makes 010B error code 267. "The directory name is invalid". Sure, that happens.

Squally answered 27/4, 2017 at 5:23 Comment(0)
T
7

This can happen for more than one reason. In my case this happened due to a permissions issue. The user that the task was running as didn't have permission to write to the logs directory so it failed with this error.

Testy answered 30/11, 2016 at 10:21 Comment(0)
E
3

For a more generic answer, convert the error value to hex, then lookup the hex value at Windows Task Scheduler Error and Success Constants

Eructate answered 19/11, 2014 at 14:16 Comment(2)
Hi Mike. I used Windows Calculator in Programmer mode to convert 2147942667 to HEX: 0x8007010B. That value does not appear in the link you provided. Just FYI, of course.Cavite
I just Googled it: 2147942667 in hex. Google's a calculator now too.Lanita
P
2

I had the same problem, on Windows7.

I was getting error 2147942667 and a report of being unable to run c:\windows\system32\CMD.EXE. I tried with and without double quotes in the Script and Start-in and it made no difference. Then I tried replacing all path references to mapped network drives and with UNC references (\Server1\Sharexx\my_scripts\run_this.cmd) and that fixed it for me. Pat.

Petasus answered 6/2, 2017 at 10:22 Comment(2)
This finally did it for me as well. I had to use "Net Use" to get the server name and then ping to get the domain name. Ultimately it was \\machine.domain.local\app.exe. \\Machine\app.exe did not workDinsdale
This is the same issue as above; mapped drives are only available during login sessions, so running the task when certain users are not logged in will mean not having those mapped drives available.Pyrrhonism

© 2022 - 2024 — McMap. All rights reserved.