Solved

Uninstaller comes second

Posted on 2006-11-29
3
190 Views
Last Modified: 2010-04-16
I have followed this article http://www.codeproject.com/useritems/DeployUninstall.asp and created uninstaller for my setup project. However, I have translated it into C# from VB.net

my code is like this:

            [STAThread]
            static void Main()
            {

                  string[] arguments = Environment.GetCommandLineArgs();

                  foreach(string argument in arguments)
                  {
                        string[] parameters = argument.Split('=');
                        if (parameters[0].ToLower() == "/u")
                        {
                              string productCode = parameters[1];
                              string path = Environment.GetFolderPath(Environment.SpecialFolder.System);
                              Process proc = new Process();
                              proc.StartInfo.FileName = string.Concat(path,"\\msiexec.exe");
                              proc.StartInfo.Arguments = string.Concat(" /i ", productCode);
                              proc.Start();
                              Application.Exit();
                        }
                  }

                  Application.Run(new Form1());
            }

The uninstaller works ok and it unistalls my project. Only once issue here is that when I click uninstaller, it starts the application first and the uninstallation window comes second.  I have put "Application.Run(new Form1());" code at last line (after uninstallation code), why it is still be executed? What can I do to avoid start the project and only uninstall it?

Thanks a lots!
0
Comment
Question by:boy8964
3 Comments
 
LVL 2

Expert Comment

by:BogdyPtr
ID: 18043530
Remove Application.Run(new Form1());
In this way the uninstaller will be started and no form will be shown.
0
 
LVL 4

Author Comment

by:boy8964
ID: 18048779
if I remove Application.Run(new Form1()); my application wot start!
0
 
LVL 3

Accepted Solution

by:
bvwang earned 500 total points
ID: 18081834
if (arguments == 1) {
Application.Run(new Form1());
}
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now