Solved

Uninstaller comes second

Posted on 2006-11-29
3
197 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

726 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