I am trying to run the following command

WsShell.Run ("WinSCP3.exe secureSFTP /console /script=fsftp.txt")

WsShell is an instance of WScript of course. I need a way for the vbs to
wait for the command to finish before it gets back the control and the next
line is executed, but vbs is taking back control too early and my command is
not running. How can I accomplish such thing? Sleep is not working.

Thanks,


--
Leo Selmani

Re: Run a command from VB Script by hempguy

hempguy
Thu Oct 12 11:13:05 CDT 2006

set the WaitOnReturn flag to True when you call the Run method.


"Leo Selmani" <LeoSelmani@discussions.microsoft.com> wrote in message
news:2780813A-DC67-4C80-AE3A-8BF8949E1805@microsoft.com...
>
> I am trying to run the following command
>
> WsShell.Run ("WinSCP3.exe secureSFTP /console /script=fsftp.txt")
>
> WsShell is an instance of WScript of course. I need a way for the vbs to
> wait for the command to finish before it gets back the control and the
> next
> line is executed, but vbs is taking back control too early and my command
> is
> not running. How can I accomplish such thing? Sleep is not working.
>
> Thanks,
>
>
> --
> Leo Selmani



Re: Run a command from VB Script by Richard

Richard
Thu Oct 12 11:20:20 CDT 2006

Leo Selmani wrote:

> I am trying to run the following command
>
> WsShell.Run ("WinSCP3.exe secureSFTP /console /script=fsftp.txt")
>
> WsShell is an instance of WScript of course. I need a way for the vbs to
> wait for the command to finish before it gets back the control and the
> next
> line is executed, but vbs is taking back control too early and my command
> is
> not running. How can I accomplish such thing? Sleep is not working.

The Run method has 2 optional parameters, one of which instructs the host to
wait for the command to finish. However, this doesn't always work. If the
program spawns another process, control will return to the script after the
program completes, but the spawned process may still be running. Try:

WshShell.Run "WinSCP3.exe secureSFTP /console /script=fsftp.txt", 0, True

The first parameter (0) means to run hidden, the second (True) means the
script will pause until the program completes. Check documentation for the
Run method of the Shell object.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net