Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Turn on session logging to file and inspect the log. If you do not find anything, post it here.
Guest

Thanks !

Set objArgs = WScript.Arguments

'WScript.Echo WScript.Arguments.Count

myFolder = Split(objArgs(0),"\")
intIndex = Ubound(myFolder)
WScript.Echo myFolder(intIndex)

Set shell = WScript.CreateObject("WScript.Shell")
'run (make it log to XML)
set exec = shell.Exec("""C:\Program Files\WinSCP\WinSCP.exe""")
' feed the commands
exec.StdIn.Write("option batch abort\n" + "open Nas\n" +"ls /share/HDA_DATA/'test\n" +"exit\n")

'wait until it finishes and collect its output
set output = exec.StdOut.ReadAll()
'optionally print the output
WScript.Echo(output)


Now it starts winscp, but it does not login and do the ls part. and logging in manually and quit Winscp gives me Objext required: '[string:""]' on set output row.

Suggestions ?
martin

Re: Help with VB script

You need to store the result of shell.Exec call to variable exec taht you are using line below:
var exec = shell.Exec("""C:\Program Files (x86)\WinSCP\WinSCP.exe""")

exec.StdIn.Write("option batch abort\n" + "open Nas\n" +"ls /share/HDA_DATA/Test\n" +"exit\n")


See documentation:
https://winscp.net/eng/docs/guide_automation_advanced#inout
Guest

Help with VB script

Hi,

I'm a total newbie at this and now my way around VB, I would like to have a script where I drop a folder, I extract the folder name and connect to a NAS where I want it to move this specific folder from one place to another with MV.

I started to make a test, but I get an error on row exec.StdIn.Write(
Set objArgs = WScript.Arguments

'WScript.Echo WScript.Arguments.Count

myFolder = Split(objArgs(0),"\")
intIndex = Ubound(myFolder)
WScript.Echo myFolder(intIndex)

Set shell = WScript.CreateObject("WScript.Shell")
'run (make it log to XML)
shell.Exec("""C:\Program Files (x86)\WinSCP\WinSCP.exe""")
' feed the commands
exec.StdIn.Write("option batch abort\n" + "open Nas\n" +"ls /share/HDA_DATA/Test\n" +"exit\n")

'wait until it finishes and collect its output
StdOut.ReadAll()
'optionally print the output
WScript.Echo(output)

 


Suggestions how I can get this to work ?