Topic "Task Scheduler/Automation Scripting Question"

Author Message
ChadBtz
[View user's profile]

Joined: 2016-12-02
Posts: 2
Location: Saginaw, MI
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. Laughing
Advertisements
ChadBtz
[View user's profile]

Joined: 2016-12-02
Posts: 2
Location: Saginaw, MI
This is the login screen that I get when WinSCP is opened every time so I need it to automatically press the login button for me since everything is already filled out
loginScreen.png (43.28 KB) [Download]

Description: (none)

martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26730
Location: Prague, Czechia
You do not want to automate the GUI ("click a button"), you need to write a script.

You can have WinSCP GUI generate the script for you (even for the transfer, not just the login):
https://winscp.net/eng/docs/ui_generateurl#script
Chad

Guest


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

Code:
@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%
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26730
Location: Prague, Czechia
Sure, because, all that script does is it opens a session and exits.
Possibly you wanted to generate a transfer script?
Read the leading section on
https://winscp.net/eng/docs/ui_generateurl
_________________
Martin Prikryl
Chad

Guest


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
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26730
Location: Prague, Czechia
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!
ChadB

Guest


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
Advertisements

You can post new topics in this forum

Search

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