Jump to content

Issues with ProccessExists() and msiexec.exe


Khasck
 Share

Recommended Posts

Hello all, I'm trying to install Avaya on users computers, and I'm running into a couple problems.

First of all, here is the script that I am currently using:

#RequireAdmin

; Create source directory
DirCreate( "C:\Utils\avtemp" )

; Copy directories
DirCopy( "default", "C:\Utils\avtemp\default", 1 )
DirCopy( "etc", "C:\Utils\avtemp\etc", 1 )

; Embed files
FileInstall( "OneXAgentSetup.exe", "C:\Utils\avtemp\OneXAgentSetup.exe", 1 )
Fileinstall( "avaya_readonly_fix.exe", "C:\Utils\avtemp\avaya_readonly_fix.exe", 1 )
FileInstall( "install.properties", "C:\Utils\avtemp\install.properties", 1 )
FileInstall( "Profiles.xml", "C:\Utils\avtemp\Profiles.xml", 1 )

; Run the installer
RunWait('"C:\Utils\avtemp\OneXAgentSetup.exe" /quiet', "C:\Utils\avtemp", @SW_HIDE )

; Wait for the installer to complete before progressing
While ProcessExists( "msiexec.exe" )
   MsgBox( 0, "Error", "Msiexec.exe is still running." )
   sleep( 1000 )
WEnd

; Clean up
DirRemove( "C:\Utils\avtemp", 1 )

Basically, when you run the Avaya executable, it opens and then runs an embedded .msi with msiexec.exe and then the setup closes while the msiexec.exe continues.
I need the script to continue running until the actual .msi setup has completed.

My issue is that the following script by itself still returns with the Msgbox, as if msiexec.exe is always running - even though it doesn't show up in Task Manager under processes. 
 

While ProcessExists( "msiexec.exe" )
   MsgBox( 0, "Error", "Msiexec.exe is still running." )
   sleep( 1000 )
WEnd

If i watch under Processes i can see msiexec.exe pop up during the installation and then after a few minutes it closes again. 
Is there any other way to wait for this installation to complete before moving on and exiting the script? 

Edited by Khasck
Link to comment
Share on other sites

It may be redundant, but I usually do something like:

$process = ProcessExists("msiexec.exe")

while $process <> 0

$process = ProcessExists("msiexec.exe")

If $process <> 0 Then

MsgBox( 0, "Error", "Msiexec.exe is still running." )

Sleep(1000)

Endif

Wend
 

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

I was messing around with it, and then I left and came back, and ran processExist msgbox error snippit alone again and no error message came up.
So for some reason, it's taking a long time to register that msiexec.exe is no longer running?

I can run the install script, see that msiexec.exe is no longer under Task Manager processes, but then I have to wait about 5-10 minutes before the script returns that it's actually not running anymore. 

Any ideas? 

 

*edit

I've replaced my processexist snippit with yours, and even though msiexec.exe is no longer under processes, the error message is still returning. 

I'm going to leave the script running to see how long it takes before I can hit "OK" and it won't come up again. 

Edited by Khasck
Link to comment
Share on other sites

Sorry for the double-post - after roughly 10 minutes, I hit "OK" and the MsgBox error closed and the installation finished.
i'm not sure why it's taking so long to register, but realistically it isn't that big of a deal. This should work for now. 

Thanks for the help. 

Link to comment
Share on other sites

That is odd. it should recheck every 10 seconds if msiexec is in the process list. Since you can clearly see it's not in task manager, then autoit shouldn't either.

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

When you are checking Task Manager, are you check for all users?  AutoIt's ProcessExists function checks for all users.  Be sure to click the "Show process from all users" button to be sure it isn't running under SYSTEM or another user.  This can happen with some installers that run start a process under the SYSTEM account.  

 

Adam

Link to comment
Share on other sites

  • 7 months later...

In the while loop, the message box stop execution of the loop until you press OK. That's why it seems like it takes too long to detect when MSIEXEC exits.  It really is waiting for you to click OK before it checks again.  

But on a larger note, you are try to force a process that should already work correctly out of the box. OneXAgentSetup.exe should stay open int he processes list until all the sub installers via MSI are done executing.  Runwait should wait until OneXAgentSetup.exe which should stay open until all the MSIExec actions are done.  

If you really want this force script to work, you'd need to grab the PID (Process ID) of the constantly running msiexec.exe so that you could exclude it from your while loop when checking to see if the "real" msiexec process has exited.   You could also try using 7-zip to extract the msi installer out of the exe file.  Then you could call msiexec direct yourself which would also work with runwait for detecting the right msiexec process.  Many times those exe file are just self contained zip files for the real installation and get in the way of scripts.

I realize this is the AutoIt site, but why would you take a simple command script and embed it into an exe?  The only reason I can think of is if you have the command prompt and thus cmd scripts blocked by group policy and this is a way of allowing users to self-install their software.  

Edited by Icono
Link to comment
Share on other sites

When you make an installation from a MSI file (like here), the Windows Installer service starts automatically : it's the first instance of msiexec.exe, running with the system account.

Msiexec is launched a second time in the user context : it's the second instance of msiexec.exe, running with the user account.

So, for a MSI based installation, you have 2 msiexec.exe running.

But now, look at the task manager after the installation : msiexec.exe is still running (it's the service, which is still running).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...