Topic "Transfering files worked in cmd prompt but not in scheduler?"

Author Message
mvneema
[View user's profile]

Joined: 2014-04-24
Posts: 6
Location: United States
Hi,

I am have been trying for past 2 days to transfer the files from ftp server to my local directory. When I tried using the winscp command prompt it worked the file was transfered but when I try automating by creating the task. It gives me the error as
"Task Scheduler failed to launch action "winscp" in instance "{e0b53590-b2d6-4380-bd56-9ce2e4d35a08}" of task "\Backup". Additional Data: Error Value: 2147942402."

Can anyone please help me since I a very new in writing the script also working in winSCP???
sampleScript.txt (119 Bytes) [Download]

Description: this was the script file I used to transfer the file from remote server to my local directory

Advertisements
JimBobDelicate

Guest


Can you provide the code please and I can help troubleshoot this. Are you trying to pass console commands to Winscp ? why not open in console mode as part of your script. What type of script?
Guest




hi,
thanks for the response. Yes I am trying to pass console commands to winscp. the script is as follows:
option batch on
option confirm off
open ftp://user:password@ftp.example.com
cd /home/user
get example.pdf Y:\
exit

I saved this script into a text file called "testScript.txt" in my C:\myScripts. And my winSCP.exe is present in C:\Program Files\WinSCP.

while creating the task, i gave the following:
In the action tab:
Program/script:
(I browse to the winSCP executable file which is "C:\Program Files\WinSCP\WinSCP.exe"
Add arguments(optional): /command "/script =C:\myScripts\testScript.txt"

I clicked finish button and the task ran with code 0x1 and did not give me an error. Can you help me on this??
mvneema
[View user's profile]

Joined: 2014-04-24
Posts: 6
Location: United States
JimBobDelicate wrote:
Can you provide the code please and I can help troubleshoot this. Are you trying to pass console commands to Winscp ? why not open in console mode as part of your script. What type of script?


hi, i just posted as guest since i didn't log in (by mistake) but that was my response.I am not able to delete it either.sorry for the confusion.
to make it more clear:

thanks for the response. Yes I am trying to pass console commands to winscp. the script is as follows:
option batch on
option confirm off
open ftp://user:password@ftp.example.com
cd /home/user
get example.pdf Y:\
exit

I saved this script into a text file called "testScript.txt" in my C:\myScripts. And my winSCP.exe is present in C:\Program Files\WinSCP.

while creating the task, i gave the following:
In the action tab:
Program/script:
(I browse to the winSCP executable file which is "C:\Program Files\WinSCP\WinSCP.exe"
Add arguments(optional): /command "/script =C:\myScripts\testScript.txt"

I clicked finish button and the task ran with code 0x1 and did not give me an error. Can you help me on this??
JimBobDelicate

Guest


Hmm,

what does the batch file look like?

Here is an example of what my batch looks like that calls my text file to pass to Winscp
"C:\Program Files (x86)\WinSCP\WinSCP.exe" /console /log="C:\example\Log Files\!S!M!D!Y!T.log" /Script=Mywinscp.txt

I should also note that when using task scheduler to automate a file transfer with a locally mapped network drive you may want to throw in a line that opens the directory as well or you will see error code 3. Also make sure you are running the automater with highest permissions. Does this help?
mvneema
[View user's profile]

Joined: 2014-04-24
Posts: 6
Location: United States
JimBobDelicate wrote:
Hmm,

what does the batch file look like?

Here is an example of what my batch looks like that calls my text file to pass to Winscp
"C:\Program Files (x86)\WinSCP\WinSCP.exe" /console /log="C:\example\Log Files\!S!M!D!Y!T.log" /Script=Mywinscp.txt

I should also note that when using task scheduler to automate a file transfer with a locally mapped network drive you may want to throw in a line that opens the directory as well or you will see error code 3. Also make sure you are running the automater with highest permissions. Does this help?


The script file (testScript.txt) has the set of commands that downloads the file to network drive. I tried the same thing you just said but I get 0x1 error code as the result. I have attached a snapshot of the history of the task been executed. I am not sure of where am i going wrong.
task_scheduler(snapshot).JPG (47.43 KB)

Description: this is the snapshot mentioned.

task_scheduler(snapshot).JPG

Clydesdale Jim

Guest


Hmm, I use a batch file that calls winscp in console mode then asks it to reference the .txt as a script. Is that what you are doing here?
mvneema
[View user's profile]

Joined: 2014-04-24
Posts: 6
Location: United States
Clydesdale Jim wrote:
Hmm, I use a batch file that calls winscp in console mode then asks it to reference the .txt as a script. Is that what you are doing here?


In the windows "BackUp" task scheduler Action tab: I have the action as start a program and Program to be
"C:\Program Files\WinSCP\WinSCP.exe"/command"/script=C:\myScript\testScript.txt". This is what I have been trying.
JimBobDelicate

Guest


mvneema wrote:
Clydesdale Jim wrote:
Hmm, I use a batch file that calls winscp in console mode then asks it to reference the .txt as a script. Is that what you are doing here?


In the windows "BackUp" task scheduler Action tab: I have the action as start a program and Program to be
"C:\Program Files\WinSCP\WinSCP.exe"/command"/script=C:\myScript\testScript.txt". This is what I have been trying.


What would happen if you changed {command"} to console. If that doesnt work you could also try putting that content in to a batch file and try running that from the task scheduler. If you encounter permission errors I would suggest creating a shortcut to the batch file that runs with admin permissions and have the task scheduler run that. I hope some of that helps you get this working Smile
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
Location: Prague, Czechia
mvneema wrote:
In the windows "BackUp" task scheduler Action tab: I have the action as start a program and Program to be
"C:\Program Files\WinSCP\WinSCP.exe"/command"/script=C:\myScript\testScript.txt". This is what I have been trying.

The /command can be removed. It does not do anything if not followed by any command. Also try to add /log=path_to_log and inspect the log (or attach it here).

"C:\Program Files\WinSCP\WinSCP.exe" /script=C:\myScript\testScript.txt /log="path_to_log"
mvneema
[View user's profile]

Joined: 2014-04-24
Posts: 6
Location: United States
prikryl wrote:
mvneema wrote:
In the windows "BackUp" task scheduler Action tab: I have the action as start a program and Program to be
"C:\Program Files\WinSCP\WinSCP.exe"/command"/script=C:\myScript\testScript.txt". This is what I have been trying.

The /command can be removed. It does not do anything if not followed by any command. Also try to add /log=path_to_log and inspect the log (or attach it here).

"C:\Program Files\WinSCP\WinSCP.exe" /script=C:\myScript\testScript.txt /log="path_to_log"


It finally worked. I gave the following
Action: Start a program
Program/script: path to your batch script e.g. C:\Users\beruk\bodo.bat
Add arguments (optional): nothing
Start in (optional): Put the full path to your batch script location e.g. C:\Users\beruk\
Then Click OK. It worked.

Thanks for the help everyone.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
Location: Prague, Czechia
See also:
https://winscp.net/eng/docs/guide_debugging_scheduler
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License