Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Want to understand why this doesn't work right, please

Reply
 
Old 02-05-2009   #1 (permalink)
Ed from AZ


 
 

Want to understand why this doesn't work right, please

I cobbled together a very basic script to run a program, sleep, run
the program again, and Echo "I'm done". Real simple:
Dim a wshell object
wshell.Run Command line
Sleep
wshell.Run Command line
wscript.Echo "I'm done"

The program does launch and run as desired. I had too long of a sleep
time at first and thought the script was done, then it suddenly
launched again! That's when I decided to cut the sleep time and put
in the Echo to tell me when the script is completed.

I think I'm missing some pretty basic understanding, though. I ran
the script, the program launched, and I got my message box before the
program finished. The program did not launch a second time. That was
not the behavior I expected! I thought the program would run and
close, THEN sleep, run and close again, THEN echo.

So I suspect the Run launches the program in a process thread totally
independant of the script? So it does the Run line and immediately
does the Sleep time? And if the program is still running by the time
Sleep is over, it may launch a second instance or it may see the first
instance still running and pass on it, and then immediately Echo?

If this is the case, is there any way I can delay the progression from
Run to Sleep and Run to Echo until the program is finished and closes
by itself?

Ed

My System SpecsSystem Spec
Old 02-05-2009   #2 (permalink)
ekkehard.horner


 
 

Re: Want to understand why this doesn't work right, please

Ed from AZ schrieb:
Quote:

> I cobbled together a very basic script to run a program, sleep, run
> the program again, and Echo "I'm done". Real simple:
> Dim a wshell object
> wshell.Run Command line
> Sleep
> wshell.Run Command line
> wscript.Echo "I'm done"
>
> The program does launch and run as desired. I had too long of a sleep
> time at first and thought the script was done, then it suddenly
> launched again! That's when I decided to cut the sleep time and put
> in the Echo to tell me when the script is completed.
>
> I think I'm missing some pretty basic understanding, though. I ran
> the script, the program launched, and I got my message box before the
> program finished. The program did not launch a second time. That was
> not the behavior I expected! I thought the program would run and
> close, THEN sleep, run and close again, THEN echo.
>
> So I suspect the Run launches the program in a process thread totally
> independant of the script? So it does the Run line and immediately
> does the Sleep time? And if the program is still running by the time
> Sleep is over, it may launch a second instance or it may see the first
> instance still running and pass on it, and then immediately Echo?
>
> If this is the case, is there any way I can delay the progression from
> Run to Sleep and Run to Echo until the program is finished and closes
> by itself?
>
> Ed
Just read the docs about the .Run method and pay close attention to the
bWaitOnReturn parameter.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
I don't understand Vista mail
This one I understand? PowerShell
I don't understand! Vista General
Can Someone Help me Understand? Vista mail
I dun understand. Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46