Jump to content

ProcessWaitClose


Eagle710
 Share

Recommended Posts

I am trying to run a msi installing as such:

Run("msiexec.exe /package c:\test.msi /passive")
ProcessWaitClose("msiexec.exe"

The ProcessWaitClose works fine for WUSA.exe and other things whatever they may be like notepad.exe but when I try and use this ProcessWaitClose with the msiexec.exe it never detects that the process has stopped running.

How if any would I be able to work around this?

I am not very familiar with looping but perhaps a ProcessExists in a loop would work more efficiently?

Any assistance would be greatly apperciated.

Edited by Eagle710
Link to comment
Share on other sites

This code works OK on my machine, does this work for you?

While 1
    If ProcessWaitClose("msiexec.exe") Then
        ConsoleWrite("Yay!" & @LF)
        ExitLoop
    EndIf
    Sleep(100)
WEnd

Oh yeah, 'msiexec.exe' needs to be running before the script is run..

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

Oh yeah, 'msiexec.exe' needs to be running before the script is run..

Does this mean it hsa to be called outside my script or just before this loop runs?

Something I noticed when outputting the variable of ProcessRun which is the PID of the process.

Msiexec.exe uses two processes to run. One using my username and the other using the System. Although the immediate msiexec.exe closes the other ones remain active for quite sometime afterwards.

Any idea how I can handle this one?

Edited by Eagle710
Link to comment
Share on other sites

$pid = ProcessWait("msiexec.exe", 99999);wait for msiexec to run (don't know how long it can wait but 99999 seconds will be enough I think)

While 1
    If ProcessWaitClose($pid) Then
        ConsoleWrite("Yay!" & @LF)
        ExitLoop
    EndIf
    Sleep(100)
WEnd

Edited by Gideon

Many times you need to think like hobby-bob:')

Link to comment
Share on other sites

Maybe I don't understand your question because I'm dutch

The first msiexec.exe that is running will get in the string $pid, so you can't wait for another msiexec in the loop.

Your script will sleep before msiexec is running and while the it's running

Many times you need to think like hobby-bob:')

Link to comment
Share on other sites

Use RunWait and instead of Run and ProcessWaitClose.

RunWait("msiexec.exe /package c:\test.msi /passive")
If you must use Run and ProcessWaitClose then do the following:

$iPID = Run("msiexec.exe /package c:\test.msi /passive")
ProcessWaitClose($iPID)

Adam

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...