Solved

Uninstaller comes second

Posted on 2006-11-29
3
189 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 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

15 Experts available now in Live!

Get 1:1 Help Now