473,394 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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.alhambra-eidos.es/web2005/index.html
www.kiquenet.com/churrosoft
http://www.setbb.com/putainformatica...opic.php?p=843
www.trabajobasura.com/solusoft

Sep 18 '08 #1
7 6432
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
http://wannabedeveloper.spaces.live.com
"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.alhambra-eidos.es/web2005/index.html
www.kiquenet.com/churrosoft
http://www.setbb.com/putainformatica...opic.php?p=843
www.trabajobasura.com/solusoft
Sep 18 '08 #2
Subscribe to the System.Diagnostics.Process.Exited 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.alhambra-eidos.es/web2005/index.html
www.kiquenet.com/churrosoft
http://www.setbb.com/putainformatica...opic.php?p=843
www.trabajobasura.com/solusoft
Sep 18 '08 #3
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.
Sep 18 '08 #4
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:\.........blah.exe" )
process.WaitForExit()


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.exe" ) )
{
process.WaitForExit( 30000 ); // Give process 30 seconds to execute (for
example)
// - this is probably far too short for
running your MSIs
if ( process.HasExited )
{
if ( process.ExitCode == 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 ( InvalidOperationException ) // Thrown by Kill(); indicates
process has already exited
{
// Same code as above reproduced here for illustrative purposes
only (should be separate method).
if ( process.ExitCode == 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.exe" );
process.WaitForExit( 30000 ); // Give process 30 seconds to execute (for
example)
// - this is probably far too short for
running your MSIs
if ( process.HasExited )
{
if ( process.ExitCode == 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 ( InvalidOperationException ) // Thrown by Kill(); indicates
process has already exited
{
// Same code as above reproduced here for illustrative purposes
only (should be separate method).
if ( process.ExitCode == 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

Sep 18 '08 #5
Do a P/Invoke to MsiInstallProduct. It's not complicated, string path to the
MSI and file the string of command line options.
--
Phil Wilson
Definitive Guide to Windows Installer
http://www.apress.com/book/view/1590592972
"Alhambra Eidos Desarrollo"
<Al*********************@discussions.microsoft.com wrote in message
news:7A**********************************@microsof t.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.alhambra-eidos.es/web2005/index.html
www.kiquenet.com/churrosoft
http://www.setbb.com/putainformatica...opic.php?p=843
www.trabajobasura.com/solusoft

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

"Alhambra Eidos Desarrollo"
<Al*********************@discussions.microsoft.com wrote in message
news:49**********************************@microsof t.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.

Sep 18 '08 #7
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 didItFinishBeforeTimeout = process.WaitForExit(1000);

--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"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.

Sep 19 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Boris Nikolaevich | last post by:
This is backwards of what I usually want--normally if you have a long-running ASP script, it's a good idea to check to see whether the client is still connected so you can cancel execution. ...
3
by: KathyB | last post by:
Hi, I'm trying to find a way to validate input text boxes where I don't know the names until the page is rendered. I've got 2 validate functions that fire with the onsubmit button of a "mini" form...
23
by: David McCulloch | last post by:
QUESTION-1: How can I detect if Norton Internet Security is blocking pop-ups? QUESTION-2a: How could I know if a particular JavaScript function has been declared? QUESTION-2b: How could I...
10
by: Gustavo L. Fabro | last post by:
Greetings! I've been porting an application for Builder to VS .NET 2003 and searching for possible bottlenecks (the application is currently running slow). I found out one scenario that takes a...
6
by: hb | last post by:
Hi, Would you please tell me how to detect if the client's browser is closed? I need such event to trigger a database modification. Thank you hb
1
by: DaveF | last post by:
Is there a way to do this, without browser Hawk? Does anyone have some code? -- David
12
by: Patrick Dugan | last post by:
I have an vb.net application that is a module that uses a "application.run" in the sub main to start. There is no form involved (just a system tray icon) How can you detect when the application...
13
by: Shailesh Humbad | last post by:
Here is an advanced PHP question. Can anyone think of a way to detect the number of bytes written to output when a script is aborted? I am sending a large file to the client, and I want to record...
2
by: Jason S | last post by:
Hi there, I created a simple VB app that runs in the background that I now need to detect when Windows (XP with SP2) is just about to Shut Down OR the user is Logging Off. Is this possible? I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.