Wshshell.run (InstallPath, 0, true) does not wait for the installation to complete and will continue the script
I am working on a project for my company to run an update on employee workstations. The file is located on a web server in our domain. The user clicks on the link and runs the script.
I made two functions to download the file to C: \ and the other to launch the installer. The file is an .exe (preferably .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 am using wshshell.run (installPath, 0, true) to execute the file. As I understand it, this should hide the installation window and wait for the execution to complete.
It will launch it, but it won't wait for the installation to complete because there are two steps in the .exe. After the "preparation to install" is complete, the script continues.
I can post Wscript.sleep. However, not all machines have the same processing speed. So, I don't know how long to wait.
Do you have any suggestion what I can do?
source to share
Usually, installation procedures spawn many processes (for example, setup.exe, msiexec.exe, install.exe, idriver.exe, etc.), and it looks like your setup.exe exits after the first step ("Preparing to Install" ) another process is running that completes the installation. In this case,
it will not help to wait for the installation to complete.
You must do this using WMI . Namely, you can subscribe to the process creation and WMI event deletion process, and thus track the creation of processes and wait for them to complete. Here's a couple of Hey, Scripting Guy! related articles:
source to share