FTP batch file works from command line, but not scheduled task












3














I want a Windows scheduled task to execute an FTP batch file which will upload some files to my server.
If I run the argument below from the command line then it executes successfully.



ftp -i -s:C:<path-to-file>ftp.dat


When I try and run this through a scheduled task it always gets to created task process and stays like this; it does not complete or fail. I have also tried this without the put commands and it still does it so it's not as if it is waiting to transfer the files.



I am creating the task through the task scheduler GUI on Windows Vista. Under the general tab I have run whether the user is logged on or not and run with highest privileges set.



Under actions it is set to run C:\WindowsSystem32cmd.exe.



And the argument is



ftp -i -s:C:<path-to-file>ftp.dat


The ftp.dat file looks like this:



open ftp.mysite.co.uk
myUsername
myPassword
put C:<path-to-file>file.xml
put C:<path-to-file>file2.xml
bye


I don't understand why this runs perfectly fine manually from the command line, but not from the scheduled task.










share|improve this question
























  • Check out this post for some helpful tips that will likely help you resolve if you've not already: superuser.com/questions/1005192/… I'll be happy to further help if you wish, just tag me back if so.
    – Pimp Juice IT
    Sep 23 '17 at 18:51
















3














I want a Windows scheduled task to execute an FTP batch file which will upload some files to my server.
If I run the argument below from the command line then it executes successfully.



ftp -i -s:C:<path-to-file>ftp.dat


When I try and run this through a scheduled task it always gets to created task process and stays like this; it does not complete or fail. I have also tried this without the put commands and it still does it so it's not as if it is waiting to transfer the files.



I am creating the task through the task scheduler GUI on Windows Vista. Under the general tab I have run whether the user is logged on or not and run with highest privileges set.



Under actions it is set to run C:\WindowsSystem32cmd.exe.



And the argument is



ftp -i -s:C:<path-to-file>ftp.dat


The ftp.dat file looks like this:



open ftp.mysite.co.uk
myUsername
myPassword
put C:<path-to-file>file.xml
put C:<path-to-file>file2.xml
bye


I don't understand why this runs perfectly fine manually from the command line, but not from the scheduled task.










share|improve this question
























  • Check out this post for some helpful tips that will likely help you resolve if you've not already: superuser.com/questions/1005192/… I'll be happy to further help if you wish, just tag me back if so.
    – Pimp Juice IT
    Sep 23 '17 at 18:51














3












3








3







I want a Windows scheduled task to execute an FTP batch file which will upload some files to my server.
If I run the argument below from the command line then it executes successfully.



ftp -i -s:C:<path-to-file>ftp.dat


When I try and run this through a scheduled task it always gets to created task process and stays like this; it does not complete or fail. I have also tried this without the put commands and it still does it so it's not as if it is waiting to transfer the files.



I am creating the task through the task scheduler GUI on Windows Vista. Under the general tab I have run whether the user is logged on or not and run with highest privileges set.



Under actions it is set to run C:\WindowsSystem32cmd.exe.



And the argument is



ftp -i -s:C:<path-to-file>ftp.dat


The ftp.dat file looks like this:



open ftp.mysite.co.uk
myUsername
myPassword
put C:<path-to-file>file.xml
put C:<path-to-file>file2.xml
bye


I don't understand why this runs perfectly fine manually from the command line, but not from the scheduled task.










share|improve this question















I want a Windows scheduled task to execute an FTP batch file which will upload some files to my server.
If I run the argument below from the command line then it executes successfully.



ftp -i -s:C:<path-to-file>ftp.dat


When I try and run this through a scheduled task it always gets to created task process and stays like this; it does not complete or fail. I have also tried this without the put commands and it still does it so it's not as if it is waiting to transfer the files.



I am creating the task through the task scheduler GUI on Windows Vista. Under the general tab I have run whether the user is logged on or not and run with highest privileges set.



Under actions it is set to run C:\WindowsSystem32cmd.exe.



And the argument is



ftp -i -s:C:<path-to-file>ftp.dat


The ftp.dat file looks like this:



open ftp.mysite.co.uk
myUsername
myPassword
put C:<path-to-file>file.xml
put C:<path-to-file>file2.xml
bye


I don't understand why this runs perfectly fine manually from the command line, but not from the scheduled task.







windows batch-file ftp windows-task-scheduler






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 27 '18 at 0:13









fixer1234

17.9k144681




17.9k144681










asked Aug 8 '13 at 15:23









Tom smith

12124




12124












  • Check out this post for some helpful tips that will likely help you resolve if you've not already: superuser.com/questions/1005192/… I'll be happy to further help if you wish, just tag me back if so.
    – Pimp Juice IT
    Sep 23 '17 at 18:51


















  • Check out this post for some helpful tips that will likely help you resolve if you've not already: superuser.com/questions/1005192/… I'll be happy to further help if you wish, just tag me back if so.
    – Pimp Juice IT
    Sep 23 '17 at 18:51
















Check out this post for some helpful tips that will likely help you resolve if you've not already: superuser.com/questions/1005192/… I'll be happy to further help if you wish, just tag me back if so.
– Pimp Juice IT
Sep 23 '17 at 18:51




Check out this post for some helpful tips that will likely help you resolve if you've not already: superuser.com/questions/1005192/… I'll be happy to further help if you wish, just tag me back if so.
– Pimp Juice IT
Sep 23 '17 at 18:51










3 Answers
3






active

oldest

votes


















0














It should work when you add "/c" as parameter for cmd.exe to run the ftp command:



C:WindowsSystem32cmd.exe
/c ftp -i -s:C:<path-to-file>ftp.dat


You can also try this 'whole' thing on the command line:



cmd /c ftp -i -s:C:<path-to-file>ftp.dat


Without "/c" it just opens a console within the console, note executing the command.






share|improve this answer





















  • Is there a reason to launch cmd when you can just run ftp directly?
    – James Snell
    Sep 23 '14 at 8:40










  • I had issues with different commands running directly which could be averted running it through cmd. Not specifically with ftp (and didn't try it), however I assumed he had similar reasons for this and wanted to change as little as possible in my answer.
    – Acrklor
    Sep 23 '14 at 9:00



















0














My suggestion would be run a VBScript script in a scheduled task:



Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.Run "C:WindowsSystem32ftp.exe -i -s:C:<path-to-file>ftp.dat", , True


I've always had much more luck with scheduling VBScript scripts over trying to scheduled commands.






share|improve this answer































    0














    It sounds like there is still a permissions or file access issue as when not running with a UI some parts of the environment are not available. It is likely that a file or path is not available since we don't know where goes...



    The best thing to do is to log the output from ftp to see if there are errors. It would be useful to have anyway to review if there are any future problems like this:



    ftp -i -s:C:<path-to-file>ftp.dat >c:ftp.log


    You could put the log file in the but it won't provide a log if you can't access that folder for some reason, so until you've ruled that out you're best to keep it in the root. Once you've ruled out that problem then you can move it to a more appropriate location.






    share|improve this answer























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "3"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f629554%2fftp-batch-file-works-from-command-line-but-not-scheduled-task%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      It should work when you add "/c" as parameter for cmd.exe to run the ftp command:



      C:WindowsSystem32cmd.exe
      /c ftp -i -s:C:<path-to-file>ftp.dat


      You can also try this 'whole' thing on the command line:



      cmd /c ftp -i -s:C:<path-to-file>ftp.dat


      Without "/c" it just opens a console within the console, note executing the command.






      share|improve this answer





















      • Is there a reason to launch cmd when you can just run ftp directly?
        – James Snell
        Sep 23 '14 at 8:40










      • I had issues with different commands running directly which could be averted running it through cmd. Not specifically with ftp (and didn't try it), however I assumed he had similar reasons for this and wanted to change as little as possible in my answer.
        – Acrklor
        Sep 23 '14 at 9:00
















      0














      It should work when you add "/c" as parameter for cmd.exe to run the ftp command:



      C:WindowsSystem32cmd.exe
      /c ftp -i -s:C:<path-to-file>ftp.dat


      You can also try this 'whole' thing on the command line:



      cmd /c ftp -i -s:C:<path-to-file>ftp.dat


      Without "/c" it just opens a console within the console, note executing the command.






      share|improve this answer





















      • Is there a reason to launch cmd when you can just run ftp directly?
        – James Snell
        Sep 23 '14 at 8:40










      • I had issues with different commands running directly which could be averted running it through cmd. Not specifically with ftp (and didn't try it), however I assumed he had similar reasons for this and wanted to change as little as possible in my answer.
        – Acrklor
        Sep 23 '14 at 9:00














      0












      0








      0






      It should work when you add "/c" as parameter for cmd.exe to run the ftp command:



      C:WindowsSystem32cmd.exe
      /c ftp -i -s:C:<path-to-file>ftp.dat


      You can also try this 'whole' thing on the command line:



      cmd /c ftp -i -s:C:<path-to-file>ftp.dat


      Without "/c" it just opens a console within the console, note executing the command.






      share|improve this answer












      It should work when you add "/c" as parameter for cmd.exe to run the ftp command:



      C:WindowsSystem32cmd.exe
      /c ftp -i -s:C:<path-to-file>ftp.dat


      You can also try this 'whole' thing on the command line:



      cmd /c ftp -i -s:C:<path-to-file>ftp.dat


      Without "/c" it just opens a console within the console, note executing the command.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Sep 23 '14 at 7:54









      Acrklor

      814




      814












      • Is there a reason to launch cmd when you can just run ftp directly?
        – James Snell
        Sep 23 '14 at 8:40










      • I had issues with different commands running directly which could be averted running it through cmd. Not specifically with ftp (and didn't try it), however I assumed he had similar reasons for this and wanted to change as little as possible in my answer.
        – Acrklor
        Sep 23 '14 at 9:00


















      • Is there a reason to launch cmd when you can just run ftp directly?
        – James Snell
        Sep 23 '14 at 8:40










      • I had issues with different commands running directly which could be averted running it through cmd. Not specifically with ftp (and didn't try it), however I assumed he had similar reasons for this and wanted to change as little as possible in my answer.
        – Acrklor
        Sep 23 '14 at 9:00
















      Is there a reason to launch cmd when you can just run ftp directly?
      – James Snell
      Sep 23 '14 at 8:40




      Is there a reason to launch cmd when you can just run ftp directly?
      – James Snell
      Sep 23 '14 at 8:40












      I had issues with different commands running directly which could be averted running it through cmd. Not specifically with ftp (and didn't try it), however I assumed he had similar reasons for this and wanted to change as little as possible in my answer.
      – Acrklor
      Sep 23 '14 at 9:00




      I had issues with different commands running directly which could be averted running it through cmd. Not specifically with ftp (and didn't try it), however I assumed he had similar reasons for this and wanted to change as little as possible in my answer.
      – Acrklor
      Sep 23 '14 at 9:00













      0














      My suggestion would be run a VBScript script in a scheduled task:



      Set WshShell = WScript.CreateObject("WScript.Shell")

      WshShell.Run "C:WindowsSystem32ftp.exe -i -s:C:<path-to-file>ftp.dat", , True


      I've always had much more luck with scheduling VBScript scripts over trying to scheduled commands.






      share|improve this answer




























        0














        My suggestion would be run a VBScript script in a scheduled task:



        Set WshShell = WScript.CreateObject("WScript.Shell")

        WshShell.Run "C:WindowsSystem32ftp.exe -i -s:C:<path-to-file>ftp.dat", , True


        I've always had much more luck with scheduling VBScript scripts over trying to scheduled commands.






        share|improve this answer


























          0












          0








          0






          My suggestion would be run a VBScript script in a scheduled task:



          Set WshShell = WScript.CreateObject("WScript.Shell")

          WshShell.Run "C:WindowsSystem32ftp.exe -i -s:C:<path-to-file>ftp.dat", , True


          I've always had much more luck with scheduling VBScript scripts over trying to scheduled commands.






          share|improve this answer














          My suggestion would be run a VBScript script in a scheduled task:



          Set WshShell = WScript.CreateObject("WScript.Shell")

          WshShell.Run "C:WindowsSystem32ftp.exe -i -s:C:<path-to-file>ftp.dat", , True


          I've always had much more luck with scheduling VBScript scripts over trying to scheduled commands.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 4 '16 at 17:13









          Peter Mortensen

          8,336166184




          8,336166184










          answered Sep 6 '13 at 6:37









          50-3

          3,66931527




          3,66931527























              0














              It sounds like there is still a permissions or file access issue as when not running with a UI some parts of the environment are not available. It is likely that a file or path is not available since we don't know where goes...



              The best thing to do is to log the output from ftp to see if there are errors. It would be useful to have anyway to review if there are any future problems like this:



              ftp -i -s:C:<path-to-file>ftp.dat >c:ftp.log


              You could put the log file in the but it won't provide a log if you can't access that folder for some reason, so until you've ruled that out you're best to keep it in the root. Once you've ruled out that problem then you can move it to a more appropriate location.






              share|improve this answer




























                0














                It sounds like there is still a permissions or file access issue as when not running with a UI some parts of the environment are not available. It is likely that a file or path is not available since we don't know where goes...



                The best thing to do is to log the output from ftp to see if there are errors. It would be useful to have anyway to review if there are any future problems like this:



                ftp -i -s:C:<path-to-file>ftp.dat >c:ftp.log


                You could put the log file in the but it won't provide a log if you can't access that folder for some reason, so until you've ruled that out you're best to keep it in the root. Once you've ruled out that problem then you can move it to a more appropriate location.






                share|improve this answer


























                  0












                  0








                  0






                  It sounds like there is still a permissions or file access issue as when not running with a UI some parts of the environment are not available. It is likely that a file or path is not available since we don't know where goes...



                  The best thing to do is to log the output from ftp to see if there are errors. It would be useful to have anyway to review if there are any future problems like this:



                  ftp -i -s:C:<path-to-file>ftp.dat >c:ftp.log


                  You could put the log file in the but it won't provide a log if you can't access that folder for some reason, so until you've ruled that out you're best to keep it in the root. Once you've ruled out that problem then you can move it to a more appropriate location.






                  share|improve this answer














                  It sounds like there is still a permissions or file access issue as when not running with a UI some parts of the environment are not available. It is likely that a file or path is not available since we don't know where goes...



                  The best thing to do is to log the output from ftp to see if there are errors. It would be useful to have anyway to review if there are any future problems like this:



                  ftp -i -s:C:<path-to-file>ftp.dat >c:ftp.log


                  You could put the log file in the but it won't provide a log if you can't access that folder for some reason, so until you've ruled that out you're best to keep it in the root. Once you've ruled out that problem then you can move it to a more appropriate location.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Jun 4 '16 at 22:02

























                  answered Sep 23 '14 at 8:51









                  James Snell

                  3231212




                  3231212






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Super User!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f629554%2fftp-batch-file-works-from-command-line-but-not-scheduled-task%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Plaza Victoria

                      Puebla de Zaragoza

                      Musa