Guest Flea# Posted March 6, 2008 Posted March 6, 2008 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/
Guest Ryan Newington Posted March 7, 2008 Posted March 7, 2008 RE: Unable to start scheduled task after creating it with Schtasks 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 "Flea#" wrote: > 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/
Guest Ryan Newington Posted March 7, 2008 Posted March 7, 2008 RE: Unable to start scheduled task after creating it with Schtasks 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 "Flea#" wrote: > 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/
Guest Dave Patrick Posted March 7, 2008 Posted March 7, 2008 Re: Unable to start scheduled task after creating it with Schtasks 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 "Flea#" wrote: > 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/
Guest Ryan Newington Posted March 7, 2008 Posted March 7, 2008 Re: Unable to start scheduled task after creating it with Schtasks 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 "Dave Patrick" wrote: > 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 > > "Flea#" wrote: > > 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/ >
Guest Flea# Posted March 7, 2008 Posted March 7, 2008 RE: Unable to start scheduled task after creating it with Schtasks 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/ "Ryan Newington" wrote: > 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 > > > "Flea#" wrote: > > > 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/
Guest Flea# Posted March 7, 2008 Posted March 7, 2008 RE: Unable to start scheduled task after creating it with Schtasks 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/ "Flea#" wrote: > 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/ > > > "Ryan Newington" wrote: > > > 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 > > > > > > "Flea#" wrote: > > > > > 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/
Guest Dave Patrick Posted March 9, 2008 Posted March 9, 2008 Re: Unable to start scheduled task after creating it with Schtasks 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 "Ryan Newington" wrote: > 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
Recommended Posts