Discussion:
Unable to start scheduled task after creating it with Schtasks
(too old to reply)
Flea#
2008-03-06 22:48:00 UTC
Permalink
Hello,

I'm using Schtasks to create a scheduled task on a remote server using the
SYSTEM account to run it. After I create the scheduled task, remote into the
server, I try and run it and it comes back with status of "Could not start".

When I view the log, it says "The system cannot find the file specified.".
The really frustrating problem is I can open the scheduled task, copy the
path and paste it into the run command and it will launch my executable. So
the path IS correct! If I delete the task and create it manually, browsing to
the same executable, it will run just fine! So it seems to be something with
creating it with Schtasks. Here is my command line: Schtasks /create /sc
DAILY /tn AMFCollector /tr "C:\Program Files\SF\AMF\AMFCollector.exe" /s
deviisvm01 /ru System /st 01:00:00

Any help would be appreciated it.
--
http://fleasharp.blogspot.com/
Ryan Newington
2008-03-07 02:11:01 UTC
Permalink
Hi,

Using C:\Progra~1\SF\AMF\AMFCollector.exe works.

For some reason, it is thinking "C:\Program" is the command, and is passing
"Files\SF\AMF\AMFCollector.exe" as an argument.

Ryan
Post by Flea#
Hello,
I'm using Schtasks to create a scheduled task on a remote server using the
SYSTEM account to run it. After I create the scheduled task, remote into the
server, I try and run it and it comes back with status of "Could not start".
When I view the log, it says "The system cannot find the file specified.".
The really frustrating problem is I can open the scheduled task, copy the
path and paste it into the run command and it will launch my executable. So
the path IS correct! If I delete the task and create it manually, browsing to
the same executable, it will run just fine! So it seems to be something with
creating it with Schtasks. Here is my command line: Schtasks /create /sc
DAILY /tn AMFCollector /tr "C:\Program Files\SF\AMF\AMFCollector.exe" /s
deviisvm01 /ru System /st 01:00:00
Any help would be appreciated it.
--
http://fleasharp.blogspot.com/
Ryan Newington
2008-03-07 02:16:01 UTC
Permalink
Actually, just read this in the schtaks help

---------------------------------
Spaces in file paths can be used by using two sets of quotes, one
set for CMD.EXE and one for SchTasks.exe. The outer quotes for CMD
need to be double quotes; the inner quotes can be single quotes or
escaped double quotes:
SCHTASKS /Create
/tr "'c:\program files\internet explorer\iexplorer.exe'
\"c:\log data\today.xml\"" ...
---------------------------------

So the correct command line syntax is

Schtasks /create /sc DAILY /tn AMFCollector /tr "'C:\Program
Files\SF\AMF\AMFCollector.exe'" /s deviisvm01 /ru System /st 01:00:00

Ryan
Post by Flea#
Hello,
I'm using Schtasks to create a scheduled task on a remote server using the
SYSTEM account to run it. After I create the scheduled task, remote into the
server, I try and run it and it comes back with status of "Could not start".
When I view the log, it says "The system cannot find the file specified.".
The really frustrating problem is I can open the scheduled task, copy the
path and paste it into the run command and it will launch my executable. So
the path IS correct! If I delete the task and create it manually, browsing to
the same executable, it will run just fine! So it seems to be something with
creating it with Schtasks. Here is my command line: Schtasks /create /sc
DAILY /tn AMFCollector /tr "C:\Program Files\SF\AMF\AMFCollector.exe" /s
deviisvm01 /ru System /st 01:00:00
Any help would be appreciated it.
--
http://fleasharp.blogspot.com/
Flea#
2008-03-07 19:21:03 UTC
Permalink
Hey Ryan,

Thanks for your reply, I really thought that might fix it up but after
running that, I still received the same error "Could not start" The system
cannot find the file specified.

I did notice one thing though. After I automatically create that task, I
notice the field for "Start in:" is blank, where as, when I manually create
the task, the "Start In" field has the path in there. On the task that is
not working, I tried putting in the path, but it still failed, but I did find
it interesting to why the start in path was not there when I used Schtask but
it was there when I manually did it.

-Flea#
--
http://fleasharp.blogspot.com/
Post by Ryan Newington
Actually, just read this in the schtaks help
---------------------------------
Spaces in file paths can be used by using two sets of quotes, one
set for CMD.EXE and one for SchTasks.exe. The outer quotes for CMD
need to be double quotes; the inner quotes can be single quotes or
SCHTASKS /Create
/tr "'c:\program files\internet explorer\iexplorer.exe'
\"c:\log data\today.xml\"" ...
---------------------------------
So the correct command line syntax is
Schtasks /create /sc DAILY /tn AMFCollector /tr "'C:\Program
Files\SF\AMF\AMFCollector.exe'" /s deviisvm01 /ru System /st 01:00:00
Ryan
Post by Flea#
Hello,
I'm using Schtasks to create a scheduled task on a remote server using the
SYSTEM account to run it. After I create the scheduled task, remote into the
server, I try and run it and it comes back with status of "Could not start".
When I view the log, it says "The system cannot find the file specified.".
The really frustrating problem is I can open the scheduled task, copy the
path and paste it into the run command and it will launch my executable. So
the path IS correct! If I delete the task and create it manually, browsing to
the same executable, it will run just fine! So it seems to be something with
creating it with Schtasks. Here is my command line: Schtasks /create /sc
DAILY /tn AMFCollector /tr "C:\Program Files\SF\AMF\AMFCollector.exe" /s
deviisvm01 /ru System /st 01:00:00
Any help would be appreciated it.
--
http://fleasharp.blogspot.com/
Flea#
2008-03-07 21:12:01 UTC
Permalink
I actually found the solution thanks to another forum
(http://www.eggheadcafe.com/software/aspnet/30582270/schtasks-doesnt-run-prog.aspx).
Turns out the problem was the quotes were being stripped off the file path in
the 'Run" field. No big deal, just need to escape the quotes out, well, not
once, twice, or three times but four times later, the quotes will finally
show up and then the task will run.

I am using powershell to run this, so I had to escape the quotes out with
its specific escape character but it looks like this:

"`"`"`"`"C:\Program Files\SF\AMF\AMFCollector.exe'`"`"`"`""
--
http://fleasharp.blogspot.com/
Post by Flea#
Hey Ryan,
Thanks for your reply, I really thought that might fix it up but after
running that, I still received the same error "Could not start" The system
cannot find the file specified.
I did notice one thing though. After I automatically create that task, I
notice the field for "Start in:" is blank, where as, when I manually create
the task, the "Start In" field has the path in there. On the task that is
not working, I tried putting in the path, but it still failed, but I did find
it interesting to why the start in path was not there when I used Schtask but
it was there when I manually did it.
-Flea#
--
http://fleasharp.blogspot.com/
Post by Ryan Newington
Actually, just read this in the schtaks help
---------------------------------
Spaces in file paths can be used by using two sets of quotes, one
set for CMD.EXE and one for SchTasks.exe. The outer quotes for CMD
need to be double quotes; the inner quotes can be single quotes or
SCHTASKS /Create
/tr "'c:\program files\internet explorer\iexplorer.exe'
\"c:\log data\today.xml\"" ...
---------------------------------
So the correct command line syntax is
Schtasks /create /sc DAILY /tn AMFCollector /tr "'C:\Program
Files\SF\AMF\AMFCollector.exe'" /s deviisvm01 /ru System /st 01:00:00
Ryan
Post by Flea#
Hello,
I'm using Schtasks to create a scheduled task on a remote server using the
SYSTEM account to run it. After I create the scheduled task, remote into the
server, I try and run it and it comes back with status of "Could not start".
When I view the log, it says "The system cannot find the file specified.".
The really frustrating problem is I can open the scheduled task, copy the
path and paste it into the run command and it will launch my executable. So
the path IS correct! If I delete the task and create it manually, browsing to
the same executable, it will run just fine! So it seems to be something with
creating it with Schtasks. Here is my command line: Schtasks /create /sc
DAILY /tn AMFCollector /tr "C:\Program Files\SF\AMF\AMFCollector.exe" /s
deviisvm01 /ru System /st 01:00:00
Any help would be appreciated it.
--
http://fleasharp.blogspot.com/
Dave Patrick
2008-03-07 03:15:06 UTC
Permalink
You should be using the AT command line scheduler for system account tasks.
--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect
Post by Flea#
Hello,
I'm using Schtasks to create a scheduled task on a remote server using the
SYSTEM account to run it. After I create the scheduled task, remote into the
server, I try and run it and it comes back with status of "Could not start".
When I view the log, it says "The system cannot find the file specified.".
The really frustrating problem is I can open the scheduled task, copy the
path and paste it into the run command and it will launch my executable. So
the path IS correct! If I delete the task and create it manually, browsing to
the same executable, it will run just fine! So it seems to be something with
creating it with Schtasks. Here is my command line: Schtasks /create /sc
DAILY /tn AMFCollector /tr "C:\Program Files\SF\AMF\AMFCollector.exe" /s
deviisvm01 /ru System /st 01:00:00
Any help would be appreciated it.
--
http://fleasharp.blogspot.com/
Ryan Newington
2008-03-07 03:37:02 UTC
Permalink
Hi Dave,

From
http://technet2.microsoft.com/windowsserver2008/en/library/2e713203-3dd8-491b-b9e1-9423618dc7e81033.mspx?mfr=true

Schtasks replaces At.exe, a tool included in previous versions of Windows.
Although At.exe is still included in the Windows Server 2003 family, schtasks
is the recommended command-line task scheduling tool.

Ryan
Post by Dave Patrick
You should be using the AT command line scheduler for system account tasks.
--
Regards,
Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect
Post by Flea#
Hello,
I'm using Schtasks to create a scheduled task on a remote server using the
SYSTEM account to run it. After I create the scheduled task, remote into the
server, I try and run it and it comes back with status of "Could not start".
When I view the log, it says "The system cannot find the file specified.".
The really frustrating problem is I can open the scheduled task, copy the
path and paste it into the run command and it will launch my executable. So
the path IS correct! If I delete the task and create it manually, browsing to
the same executable, it will run just fine! So it seems to be something with
creating it with Schtasks. Here is my command line: Schtasks /create /sc
DAILY /tn AMFCollector /tr "C:\Program Files\SF\AMF\AMFCollector.exe" /s
deviisvm01 /ru System /st 01:00:00
Any help would be appreciated it.
--
http://fleasharp.blogspot.com/
Dave Patrick
2008-03-09 00:26:19 UTC
Permalink
Ok, thanks for letting us know.
--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect
Post by Ryan Newington
Hi Dave,
From
http://technet2.microsoft.com/windowsserver2008/en/library/2e713203-3dd8-491b-b9e1-9423618dc7e81033.mspx?mfr=true
Schtasks replaces At.exe, a tool included in previous versions of Windows.
Although At.exe is still included in the Windows Server 2003 family, schtasks
is the recommended command-line task scheduling tool.
Ryan
Loading...