Detect when MSI finish

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?=

    #1

    Detect when MSI finish

    Hi all, misters,

    I have Windows App .net 2.0 + vs 2005. My form launch several MSI's
    (app1.msi, app2.msi).

    I try launch MSI using Process.Start.

    I need know when detect MSI executable has finished ? Perphaps, I launch MSI
    and wait it until finish.

    Any suggestions or sample code source ??

    Thanks in advance, greetings.

    --


    http://www.setbb.com/putainformatica...opic.php?p=843


  • =?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?=

    #2
    RE: Detect when MSI finish

    I think when you launch the MSI you need to launch MSEExec which is the
    program that actually runs the install. You should then be able to pass
    parameters as to which MSI and then WaitForExit on the process object.


    --
    Ciaran O''Donnell



    "Alhambra Eidos Desarrollo" wrote:
    Hi all, misters,
    >
    I have Windows App .net 2.0 + vs 2005. My form launch several MSI's
    (app1.msi, app2.msi).
    >
    I try launch MSI using Process.Start.
    >
    I need know when detect MSI executable has finished ? Perphaps, I launch MSI
    and wait it until finish.
    >
    Any suggestions or sample code source ??
    >
    Thanks in advance, greetings.
    >
    --


    http://www.setbb.com/putainformatica...opic.php?p=843

    >

    Comment

    • =?Utf-8?B?RmFtaWx5IFRyZWUgTWlrZQ==?=

      #3
      RE: Detect when MSI finish

      Subscribe to the System.Diagnost ics.Process.Exi ted event.

      "Alhambra Eidos Desarrollo" wrote:
      Hi all, misters,
      >
      I have Windows App .net 2.0 + vs 2005. My form launch several MSI's
      (app1.msi, app2.msi).
      >
      I try launch MSI using Process.Start.
      >
      I need know when detect MSI executable has finished ? Perphaps, I launch MSI
      and wait it until finish.
      >
      Any suggestions or sample code source ??
      >
      Thanks in advance, greetings.
      >
      --


      http://www.setbb.com/putainformatica...opic.php?p=843

      >

      Comment

      • =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?=

        #4
        RE: Detect when MSI finish

        Thanks all,

        One potential problem is that this version of WaitForExit() will wait
        forever if the process never finishes, for example if it hangs.

        Any suggestions for resolves this problem ?? Any good sample code about it ?

        Thanks.


        Comment

        • =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?=

          #5
          RE: Detect when MSI finish

          need know when detect MSI executable has finished ? Perphaps, I launch MSI
          and wait it until finish.


          Can do this:



          Dim process as Process = Process.Start( "C:\.........bl ah.exe" )
          process.WaitFor Exit()




          In forums, Bart Read says (in C# forums):

          One potential problem is that this version of WaitForExit() will wait
          forever if the process never finishes, for example if it hangs. Obviously,
          you'd hope that wouldn't happen with the MSIs you're running, but just in
          case, it might be worth taking into account. Also I haven't at all considered
          what might happen if the MSI exits with a failure code (non-zero exit code).
          Process also implements IDisposable, so once you're done with the object you
          should call Dispose().

          This sample takes these things into account:

          using ( Process process = Process.Start( "C:\.....blah.e xe" ) )
          {
          process.WaitFor Exit( 30000 ); // Give process 30 seconds to execute (for
          example)
          // - this is probably far too short for
          running your MSIs
          if ( process.HasExit ed )
          {
          if ( process.ExitCod e == 0 ) // Success
          {
          HandleSuccess() ;
          }
          else
          {
          HandleFailure() ;
          }
          }
          else
          {
          try
          {
          // You might also want to kill the process, although with an MSI
          this is not a good idea because you're almost
          // certainly going to leave your system in an inconsistent
          state. Anyway, if you do want to kill the process:
          process.Kill();

          // Maybe display timeout message or throw exception indicating
          timeout.
          }
          catch ( InvalidOperatio nException ) // Thrown by Kill(); indicates
          process has already exited
          {
          // Same code as above reproduced here for illustrative purposes
          only (should be separate method).
          if ( process.ExitCod e == 0 ) // Success
          {
          HandleSuccess() ;
          }
          else
          {
          HandleFailure() ;
          }
          }
          catch ( Win32Exception w32e ) // Thrown by Kill() if, e.g., process
          can't be terminated
          {
          // Do exception handling: e.g. display error to user, or wrap
          and rethrow
          }
          }
          }

          That's probably enough to be going on with, however if you're distributing
          your application to a very large number of peope and you don't really like,
          or trust using (like me), then you might want to do the following, which is a
          little more foolproof (some people don't like this idiom though):

          Process process = null;
          try
          {
          process = Process.Start( "C:\.....blah.e xe" );
          process.WaitFor Exit( 30000 ); // Give process 30 seconds to execute (for
          example)
          // - this is probably far too short for
          running your MSIs
          if ( process.HasExit ed )
          {
          if ( process.ExitCod e == 0 ) // Success
          {
          HandleSuccess() ;
          }
          else
          {
          HandleFailure() ;
          }
          }
          else
          {
          try
          {
          // You might also want to kill the process, although with an MSI
          this is not a good idea because you're almost
          // certainly going to leave your system in an inconsistent
          state. Anyway, if you do want to kill the process:
          process.Kill();

          // Maybe display timeout message or throw exception indicating
          timeout.
          }
          catch ( InvalidOperatio nException ) // Thrown by Kill(); indicates
          process has already exited
          {
          // Same code as above reproduced here for illustrative purposes
          only (should be separate method).
          if ( process.ExitCod e == 0 ) // Success
          {
          HandleSuccess() ;
          }
          else
          {
          HandleFailure() ;
          }
          }
          catch ( Win32Exception w32e ) // Thrown by Kill() if, e.g., process
          can't be terminated
          {
          // Do exception handling: e.g. display error to user, or wrap
          and rethrow
          }
          }

          process.Dispose (); // If this throws an exception you'll know about it;
          whereas if another exception is thrown
          // elsewhere this idiom means that an exception
          thrown by Dispose() won't mask it.
          process = null;
          }
          finally
          {
          if ( process != null )
          {
          try { process.Dispose (); } catch ( Exception ) {}
          }
          }

          Any good solution about it ? I think is better use another Thread, but for
          me the problem is how kill the process if MSI hangs or fails ??



          Please, MVPs or Microsoft developers, which is the better solution or
          solutions for this issue ???



          I want to do good practice !!!


          Any suggestions or good sample code source about it??

          Thanks in advance, greetings



          Comment

          • Phil Wilson

            #6
            Re: Detect when MSI finish

            Do a P/Invoke to MsiInstallProdu ct. It's not complicated, string path to the
            MSI and file the string of command line options.
            --
            Phil Wilson
            Definitive Guide to Windows Installer



            "Alhambra Eidos Desarrollo"
            <AlhambraEidosD esarrollo@discu ssions.microsof t.comwrote in message
            news:7AF043A5-C195-498C-949E-7DCB2B36AA8F@mi crosoft.com...
            Hi all, misters,
            >
            I have Windows App .net 2.0 + vs 2005. My form launch several MSI's
            (app1.msi, app2.msi).
            >
            I try launch MSI using Process.Start.
            >
            I need know when detect MSI executable has finished ? Perphaps, I launch
            MSI
            and wait it until finish.
            >
            Any suggestions or sample code source ??
            >
            Thanks in advance, greetings.
            >
            --


            http://www.setbb.com/putainformatica...opic.php?p=843

            >

            Comment

            • Family Tree Mike

              #7
              Re: Detect when MSI finish

              Well, I said handle the Process.Exited event. If it doesn't occur in 24
              hours, you could kill it.

              "Alhambra Eidos Desarrollo"
              <AlhambraEidosD esarrollo@discu ssions.microsof t.comwrote in message
              news:49D621D4-AAD4-47B2-84D3-B15829E1BF3B@mi crosoft.com...
              Thanks all,
              >
              One potential problem is that this version of WaitForExit() will wait
              forever if the process never finishes, for example if it hangs.
              >
              Any suggestions for resolves this problem ?? Any good sample code about it
              ?
              >
              Thanks.
              >
              >

              Comment

              • =?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?=

                #8
                RE: Detect when MSI finish

                WaitForExit has an overload which takes a number of milliseconds to return
                after if the process hasnt exited and returns a bool to say whether it
                finished in time or not.

                e.g

                bool didItFinishBefo reTimeout = process.WaitFor Exit(1000);

                --
                Ciaran O''Donnell



                "Alhambra Eidos Desarrollo" wrote:
                Thanks all,
                >
                One potential problem is that this version of WaitForExit() will wait
                forever if the process never finishes, for example if it hangs.
                >
                Any suggestions for resolves this problem ?? Any good sample code about it ?
                >
                Thanks.
                >
                >

                Comment

                Working...