Task Scheduler/Automation Scripting Question

Advertisement

ChadBtz
Joined:
Posts:
2
Location:
Saginaw, MI

Task Scheduler/Automation Scripting Question

I am trying to make it so that when the task is ran WinSCP automatically can log me in > grab files from specific folders > then push them out to others.

Right now I am trying to figure out a script that will log me in to the system. When I open WinSCP on my own it automatically fills out the login information that I need so all i need it to do is press the login button then I can move onto the next problem of moving the files.

Thank you in advance if anyone can help me figure this out. :lol:

Reply with quote

Advertisement

Chad
Guest

Follow Up

So this is the code that WinSCP generated for me with the personal information *'ed out.

When I run the batch file it says,
Connecting to sftp.******.com ...
Connected
Starting the session...
Session started.
Active session: [1] **********@sftp.****.com
Success

And then after this it just closes and nothing else happens.
Any ideas on how I can move forward with this problem?

Thanks

@echo off

"C:\Program Files\WinSCP\WinSCP.com" ^
  /log="C:\writable\path\to\log\WinSCP.log" /ini=nul ^
  /command ^
    "open ftp://**************:***********@sftp.******.com/" ^
    "exit"

set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)

exit /b %WINSCP_RESULT%

Reply with quote

Advertisement

Chad
Guest

OK So....

In Task Scheduler I have it opening WinSCP, then in the arguments part I inserted the ftp:// with where I want to connect to.
It opens up correctly, but I am in the wrong directory for the documents I need to upload.

Is there a way to in the arguments put me in for example the S Drive on my PC?
Or is there a way to just upload straight from where I want to take the documents from and upload them without being in the correct drive?

Thanks

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
32,977
Location:
Prague, Czechia

Re: OK So....

Sure, you can use a full path in the put command, like put S:\*.* /remote/path/. Or use the lcd command before the upload, like lcd S:\ ... put *.* /remote/path/. Again, that's what the generated script does for you already, had you used the correct directories to generate it!

Reply with quote

ChadB
Guest

Got it for now

Thank you Martin. I wasn't able to actually transfer files with my permissions so I never saw the generate code part.

Sorry for the continued questions :wink:

The answers were helpful though for me to get where I needed to go and continue to search around. If I run into any more problems I will let you know.

Thanks

Reply with quote

Advertisement

You can post new topics in this forum