167

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?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Alok
  • 3,160
  • 3
  • 28
  • 47
  • 51
    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. – Hans Passant Jun 19 '13 at 10:59
  • 1
    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. – Neek Dec 03 '15 at 04:25
  • 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. – jrobiii Jun 09 '17 at 18:29
  • 1
    To tie into @HansPassant's excellent comment: https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes – Ian Kemp Sep 05 '19 at 09:30
  • 2
    @Mark Berry https://learn.microsoft.com/en-us/windows/win32/com/structure-of-com-error-codes – R.J. Dunnill Jul 31 '20 at 17:41

5 Answers5

326

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.

TylerH
  • 20,799
  • 66
  • 75
  • 101
  • 7
    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. – shufler Aug 14 '13 at 21:47
  • 2
    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. – Mark Berry Jul 17 '14 at 00:20
  • 1
    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:\ – Morpork Mar 25 '15 at 08:29
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.

user230910
  • 2,353
  • 2
  • 28
  • 50
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.

Cookalino
  • 1,559
  • 14
  • 19
2

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

flymike
  • 935
  • 2
  • 9
  • 18
  • 3
    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. –  Feb 23 '15 at 15:58
  • 4
    I just Googled it: `2147942667 in hex`. Google's a calculator now too. – Baodad Apr 11 '16 at 17:03
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.

Pat Fahy
  • 109
  • 1
  • 5
  • 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 work – greg Sep 27 '17 at 11:29
  • 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. – TylerH Jun 07 '22 at 14:48