When some Windows users tried running a job using Task Scheduler they got an error. According to the victims, there is nothing wrong with the job’s script as it runs perfectly, but they still cannot schedule it. In this post, we will see what you can do if you get The directory name is invalid error in Task Scheduler with error code 2147942667 or any other.
What does the Directory name isn’t valid mean?
If the Directory name isn’t valid, you need to change the path mentioned in the “Start in” field. More often than not, a special character gets added to the path, which you can remove to resolve the issue. Hereinafter, we have mentioned every single solution that is required to resolve this issue.
Fix The directory name is invalid error in Task Scheduler
If you get The directory name is invalid error in Task Scheduler, the very first you need to do is run Task Scheduler as an administrator. Once done, check if the issue is resolved. In case, launching the app with administrative privilege is to no avail, follow the solutions mentioned below to resolve the issue.
- Delete and then add the task
- Edit the file path
- Task control of the directory
- Replace path preferences
Let us talk about them in detail.
1] Delete and then add the task
It is possible that the task is not getting scheduled due to some glitch. Usually, glitches can be resolved by just rebooting the system. You should do that first and then see if the issue is resolved. However, in this case, rebooting might not work. That is why, you need to delete the task and then add it again. After doing so, schedule it and check if it’s working.
2] Edit the file path
As mentioned in the error message, the directory name, which is nothing but its absolute path is incorrect. A very common issue that a lot of users notice, a special character is being added to the path, due to which the system is unable to read it. We can pretty quickly make the modification to the path as that will do the job for us. To do the same, just follow the steps given below.
- Open Task Scheduler by searching it out of the Start Menu.
- Then click on the Task Scheduler Library from the right side of the window.
- Now, go to the task that you want to schedule, right-click on it, and select Properties.
- Go to the Actions tab, select the path, and click on the Edit button.
- Next, go to the Start in (optional) field and then remove the Quotes (” “) from the path.
- Once done, click on the Ok button to save your changes.
After making the changes, re-schedule the file and then check if the issue is resolved. Hopefully, this will do the job for you.
3] Take control of the directory
You will not be able to run the task if the file specified in the task is not made available to you, that is, you don’t have permission to access it. You must have permission to access the folder or perform operations in it, but if you don’t, there is a way to take control of it. All that is required from your side is to follow the steps mentioned below.
- Open the File Explorer and navigate to the folder.
- Right-click on it and select Properties.
- Now, go to Security.
- Then you have to click on Edit.
- Select the user and tick the box associated with Full Control.
- Finally, click on Apply > Ok to save the changes that you have made.
After performing the task, you may have to reschedule the job. Hopefully, this time you won’t get any error.
4] Replace path references
Sometimes, all that needs to replace this issue is to replace all path references to mapped network drives and with UNC references, as that will resolve the issue for you.
We hope that you can resolve the issue using the solutions mentioned in this post.
How do I fix the directory name is invalid?
The Directory name is an invalid error in Task Scheduler that appears when the name of the path, which in this case is nothing but location, is incorrect. More often than not, the path itself is correct, but there are special characters added to it, in most cases, a quotation mark which makes, which causes the problem. We have mentioned steps on how to make these changes earlier in this post along with some other solutions required to resolve the issue.