How to Execute Files in The Task Scheduler That Have Spaces

Don't hesitate to apply our quick procedure right away

Reading time icon 3 min. read

Readers help support Windows Report. We may get a commission if you buy through our links. Tooltip Icon

Read our disclosure page to find out how can you help Windows Report sustain the editorial team Read more

Some utilize Task Scheduler to set up scheduled tasks that open software and files. However, those scheduled tasks might not always work for users. That is often because the files the tasks need to open include spaces in their file titles.

Consequently, a scheduled task might not open the software or a file it’s supposed to. However, it’s relatively easy to fix scheduled tasks that don’t open files with spaces.

How can I fix scheduled tasks that include files with spaces?

1. Add quote marks to the file paths

  1. Users can fix the scheduled tasks by adding quotation marks around the paths that include file (or folder) spaces. To do that, press the Windows key + S hotkey to open the search utility.
  2. Enter ‘Task Scheduler’ in the search box.
  3. Click Task Scheduler to open the window shown directly below.Task Scheduler how to execute files in the Task Scheduler that have spaces
  4. Double-click Task Scheduler Library on the left of the window to expand it.
  5. Select the folder that includes the scheduled task that needs fixing.
  6. Then right-click the scheduled task and select Properties.
  7. Select the Actions tab in the snapshot directly below.Actions tab how to execute files in the Task Scheduler that have spaces
  8. Select Start a program, and then press the Edit button. The Edit Action window will then open.Edit Action window how to execute files in the Task Scheduler that have spaces
  9. If the Program/script path does not include quotation marks around it, add them to the beginning and end of the path.
  10. Then add quotation marks at the beginning and end of the file path in the Add arguments box.
  11. Click the OK button.
  12. Then press the OK button on the properties window.

2. Delete spaces from file titles

  1. Alternatively, try deleting spaces from file and folder titles within the paths included for the scheduled task. To do that, open File Explorer with the Windows key + E hotkey.
  2. Then open the folder that includes the task file with spaces in it.
  3. Right-click the file and click the Rename option.The Rename option how to execute files in the Task Scheduler that have spaces
  4. Delete all the spaces from the file title.
  5. Then press the Enter key.
  6. If any of the folder titles within the software or file paths include spaces, remove the spaces from the folder titles.

3. Add backslash and quote marks to file paths in the Command Prompt

Users who utilize the Schtasks.exe Command Prompt utility to schedule tasks need to include additional backslash (\) and quote (“) marks around the file path with spaces (excluding arguments or switches) within the command. For example, a file path with arguments in the schtasks /create command would look something like this:

\”c:\foldername with spaces\file.bat\” arguments”

Instead of this:

“c:\foldername with spaces\file.bat arguments”

The example above encloses the first file path within  “\ and \” character combinations. However, arguments is left outside the character combinations, but it is still enclosed within the quote marks. With those character combinations included around the path, the task will run at the time scheduled within the command. A full command might look like the one in the snapshot below.

The schtasks command how to execute files in the Task Scheduler that have spaces

So, users can add quotation marks to the file paths in the Edit Action window, remove spaces from file paths, or add character combinations around file paths that include spaces in Schtasks commands. Then, the scheduled tasks should work.

If you are facing the Task Scheduler failed to launch an action issue, we suggest you check out this solution guide.

More about the topics: task scheduler