Microsoft KB Archive/823093

= A Scheduled Task Does Not Run When You Use Schtasks.exe to Create It and When the Path of the Scheduled Task Contains a Space =

Article ID: 823093

Article Last Modified on 10/30/2006

-

APPLIES TO


 * Microsoft Windows Server 2003, Web Edition
 * Microsoft Windows Server 2003, Standard Edition (32-bit x86)
 * Microsoft Windows Server 2003, Enterprise Edition (32-bit x86)

-





SYMPTOMS
When you use the Scheduled Tasks Wizard to schedule a task, the task runs as you expect. However, if you use the Schtasks.exe command-line tool to create a schedule for the same task, the task does not run at the time when you scheduled it. Additionally, when you view the task in the Scheduled Tasks dialog box, the following text appears in the Status column:

Could not start



CAUSE
This problem occurs if the path of the scheduled task contains a space. For example, this problem occurs if you create a schedule for the following task by using Schtasks.exe:

&quot;c:\ \task.bat&quot;

In this example, Schtasks.exe treats everything after the first space in the path as a command-line argument.



WORKAROUND
To work around this problem, enclose the path portion of the task (not including arguments or switches) between backslash (\) and quotation marks (&quot;) character combinations, for example \&quot;. Enclose the complete path of the task (including arguments or switches) between quotation marks as usual when you create a path or command that contains spaces.

For example, the following example task does not run when you schedule it:

schtasks /create /tn &quot;my task&quot; /tr &quot;c:\foldername containing spaces\script.bat arguments&quot; /sc once /sd 07/29/2003 /st 10:01

However, when you enclose the path of the task between the backslash and quotation marks character combinations as in the following example, the scheduled task runs successfully:

schtasks /create /tn &quot;my task&quot; /tr &quot;\&quot;c:\foldername name containing spaces\script.bat\&quot; arguments&quot; /sc once /sd 07/29/2003 /st 10:01

Additional query words: sctasks

Keywords: kbprb kbnofix kbbug KB823093

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.