Windows Vista Forums

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


    Ed from AZ Guest

    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

  2. #2


    ekkehard.horner Guest

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

    Ed from AZ schrieb:

    > 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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Vista doesn't boot and startup repair doesn't work mrdogcat Vista General 4 02 Feb 2010
I Do Not Understand How Mail Progams Work MrSteve Live Mail 9 02 Feb 2010
Still searching for way to get Vista search to work: Why doesn't FilterFilesWithUnknownExtensions registry key work in Vista? Celegans Vista General 11 31 Aug 2007
Some administrator work doesn't work Rem-8 Vista General 4 19 May 2007
It Just doesn't work help!! Grokking Vista mail 3 25 Feb 2007