Topic "run WinSCP from vbs"

Author Message
Leo
[View user's profile]

Joined: 2006-10-02
Posts: 4
Location: Toronto
So I am trying to run a command on WinSCP from VBS, but it does not run. Is there a way to accomplish this?

wshShell.Run("WinSCP3.exe secureSFTP /console /script=fsftp.txt"),1,True

see, when it tries to run the txt file, it closes. Is there a way to make it wait? How can I do this?

Thanks
Leo
Advertisements
Leo
[View user's profile]

Joined: 2006-10-02
Posts: 4
Location: Toronto
never mind. got it

if anyone will benefit from this (and doesn't know how to), here's what I did

From VBS, it seems impossible to run an WinSCP script that resides in a txt file. Therefore this will not work:

Dim wshShell
Set wshShell = WScript.CreateObject("WScript.Shell")
wshShell.Run("WinSCP3.exe secureSFTP /console /script=fsftp.txt"),1,True

Putting the above code in a bat file and trying to execute the bat file from VBS had the same issue. I tried several techniques but none worked, until this

Dim wshShell
Dim sftpcmd
Set wshShell = WScript.CreateObject("WScript.Shell")
sftpcmd = "WinSCP3 secureSFTP /console /command " & """option batch on""" & " " & """option confirm off""" & " " & """cd /Dex""" & " " & """option transfer binary""" & " " & """get securefile.txt.pgp C:\\SecureFileDump\\Archive\\""" & " " & """close""" & " " & """exit"""

wshShell.Run(sftpcmd),1,true

wscript.sleep(10000) 'wait for 10 seconds until sftp is done

Maybe this is not a big thing, but I thought I'd put it up here for someone's benefit


Thanks
Leo

Leo wrote:
So I am trying to run a command on WinSCP from VBS, but it does not run. Is there a way to accomplish this?





see, when it tries to run the txt file, it closes. Is there a way to make it wait? How can I do this?

Thanks
Leo
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
Leo wrote:
So I am trying to run a command on WinSCP from VBS, but it does not run. Is there a way to accomplish this?

wshShell.Run("WinSCP3.exe secureSFTP /console /script=fsftp.txt"),1,True

Have you tried to specify full path? Would it help?
_________________
Martin Prikryl
Leo
[View user's profile]

Joined: 2006-10-02
Posts: 4
Location: Toronto
Hi Martin. Yes as a matter of fact I did try that. The problem is not with WinSCP, it's with how WSCRIPT will execute a batch file that in turns executes a program, which in turn takes its commands from a text file. The execution hierarchy is long in this case, and the Test file gets no priority, and there was no (easy) way to get the WinSCP script to open and execute the commands in the .txt file. However as I wrote above, I did find the solution, by directly running the WinSCP script from within the VBS file, and passing the commands through the /command switch. It works perfectly. Thanks for the help


Leo

prikryl wrote:
Leo wrote:
So I am trying to run a command on WinSCP from VBS, but it does not run. Is there a way to accomplish this?

wshShell.Run("WinSCP3.exe secureSFTP /console /script=fsftp.txt"),1,True

Have you tried to specify full path? Would it help?
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