tags:

views:

277

answers:

2

Good afternoon,

I'm working on a project for my company to run an update on the employees workstations. The file is located on a webserver on our domain. The user will click on a link and start up the script.

I made two functions one to download the file to the C:\ and another to run the installer. The file is a .exe (I wish it was a .msi).

'' //executes the file at the location: installPath
Function launchUpdate(installPath)
    dim wshShell
    Set wshShell = WScript.CreateObject ("WSCript.shell")
    errReturn =  wshshell.run(installPath, 6, true)
End function

I'm using wshshell.run(installPath, 0, true) to execute the file. From what I understand, this should hide the install window and wait until the execution is complete.

It will start it up but it will not wait to complete the install because there are two steps in the .exe. Once the "preparing to install" is done, the script goes on with its job.

I could place Wscript.sleep. However, not all the machine have the same processing speed. So, I will not know how long to wait.

Do you have any suggestion what I could do?

Thank you,

Brian

A: 

It sounds like your setup file is spawning another process, and then exiting. If that's the case there's nothing you can do except maybe write a "wrapper" executable that waits for both processes to terminate, and invoking that instead.

Ian Kemp
+2  A: 

Installation procedures usually spawn multiple processes (e.g. setup.exe, msiexec.exe, install.exe, idriver.exe etc), and it looks like your setup.exe exits after the first step ("Prepare to install") having launched another process that completes the installation. In this case WshShell.Run won't help wait for the installation to finish.

You should be able to do this using WMI, though. Namely, you can subscribe to the process creation and process deletion WMI events and this way monitor the creation of processes and wait for them to end. Here's a couple of the Hey, Scripting Guy! articles on the subject:

Helen
I just had to find what process started up and that did the trick. It was very helpful and very well writen too. Thank you!-Brian
Illure