Uninstall option in toolbar

Add-in Express™ Support Service
That's what is more important than anything else

Uninstall option in toolbar
I want to crate a uninstall button in the toolbar (without using Control Panel) 
Ronald Abegg




Posts: 21
Joined: 2011-03-25
Hello,

I'm trying to create an uninstall button in my toolbar, so the user doesn't have to go to the control panel to do so; I looked in the documentation and in your site but I didn't find anything, it only says the uninstall process can be made in the control panel.

Is there another way to do it other than CP? Or at least to get the path to the MSI file to run it from a button?

Thanks in advance.

Ron.-
Posted 28 Apr, 2011 13:09:20 Top
Ronald Abegg




Posts: 21
Joined: 2011-03-25
Another thing I want to do, is to automatically run IE after installation, how can I set this up in my project?

Thanks again
Posted 28 Apr, 2011 18:49:35 Top
Sergey Grischenko


Add-in Express team


Posts: 7224
Joined: 2004-07-05
Hi Ronald,

To uninstall the product you can use the msiexec.exe tool. Just run 'msiexec.exe /?' to get the list of supported keys.

To run IE (and any other applications) programmatically you can use the System.Diagnostics.Process class of the .NET Framework.
Posted 29 Apr, 2011 05:34:52 Top
Ronald Abegg




Posts: 21
Joined: 2011-03-25
Thanks a lot Sergey!

I see I can use the 'msiexec.exe /x path_to.msi' to uninstall the toolbar from a button, but how can I get the full path of the MSI file?

About running IE, I know I can use System.Diagnostics.Process, but how do I call the process automatically after the installation? Something like adding iexplore.exe to my installer Custom Actions in the Install folder...

Thanks again, I'll be googling for a solution in the meantime :)

Ron.-
Posted 29 Apr, 2011 13:03:31 Top
Yahya Kamran




Posts: 8
Joined: 2010-06-03
Hi,

First you need to create your own custom Installer Class and it could be part of your own application's class collection or a standalone dll. You need to integrate installer class with your Setup and Deployment Project (Custom Action) in order to perform additional tasks. You basically override the method
protected override void OnAfterInstall(IDictionary savedState)
to execute the IE at end of installation.




using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;

namespace MyInstallerClassDll
{
    [RunInstaller(true)]
    public partial class MyInstallerClass : Installer
    {
        public MyInstallerClass()
        {
            InitializeComponent();
        }
    }

    protected override void OnAfterInstall(IDictionary savedState)
    {
        base.OnAfterInstall(savedState);
        // Use System.Diagnostics.Process class to execute any process.
    }
}



But above process launches under Windows built-in user SYSTEM (Local System Account).

@Sergey

How do we impersonate user without knowing the username/password for currently logged-in user? So that process launches under the currently logged-in user.
Posted 29 Apr, 2011 23:59:50 Top
Sergey Grischenko


Add-in Express team


Posts: 7224
Joined: 2004-07-05
Hi Yahya, thank you for the help.

How do we impersonate user without knowing the username/password for currently logged-in user? So that process launches under the currently logged-in user.

You need to use the following script:
http://blogs.msdn.com/b/astebner/archive/2006/10/23/mailbag-how-to-set-the-noimpersonate-flag-for-a-custom-action-in-visual-studio-2005.aspx
Posted 02 May, 2011 05:59:18 Top
Sergey Grischenko


Add-in Express team


Posts: 7224
Joined: 2004-07-05
Hi Ronald,

You don't need the full path to the MSI file. You can use the product code to uninstall it.
The product code is set in the properties of your setup project.
Posted 02 May, 2011 06:01:21 Top
Ronald Abegg




Posts: 21
Joined: 2011-03-25
Thanks a lot! Got it working now :) in case anyone else needs the same thing, this is my c# installer class:

file MyInstallerClass.cs


using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
using System.Diagnostics;

namespace MyToolbar01
{
    [RunInstaller(true)]
    public partial class MyInstallerClass : Installer
    {
        public MyInstallerClass()
        {
            InitializeComponent();
        }
        protected override void OnAfterInstall(IDictionary savedState)
        {
            base.OnAfterInstall(savedState);
            try
            {
                Process ie = new Process();
                ie.StartInfo.FileName = "iexplore";
                ie.StartInfo.Arguments = "http://mysiteurl.com/installed.php";
                ie.Start();
            }
            catch
            {
                throw;
            }
        }
    }
}


And the uninstall button has this code:

Process uninstaller = new Process();
uninstaller.StartInfo.FileName = "msiexec";
uninstaller.StartInfo.Arguments = "/x {PRODUCT_CODE_GOES_HERE}";
uninstaller.StartInfo.UseShellExecute = false;
uninstaller.StartInfo.RedirectStandardOutput = true;
uninstaller.StartInfo.Verb = "runas";
uninstaller.Start();


I had to publish my installer and sign it to make it work.

Thanks again guys!

Ron.-
Posted 03 May, 2011 15:43:12 Top
Ronald Abegg




Posts: 21
Joined: 2011-03-25
Hi again!

I'm testing my toolbar in different OS, I have a fresh install of WinXP Professional SP2 with IE6 in a VirtualBox; the installer doesn't stop asking me to download and install .NET Framework 4, the first time I downloaded and installed it then restart the OS, now if I try to repeat the process the toolbar setup file ask me for .NET Framework 4 again to be installed, but the .NET Framework installer ask me if I want to repair or remove (i.e. is already installed)

Is there a log where I can look what might be wrong? Also, what's the best option you recommend me for my toolbar installer in matter or prerequisites? Is really annoying to download a 80 Mb file, install it, restart the PC, only to install my 3Mb toolbar.

Thanks again for all the help!

Ron.-
Posted 04 May, 2011 10:43:04 Top
Sergey Grischenko


Add-in Express team


Posts: 7224
Joined: 2004-07-05
Hi Ron.

Do you install the Windows Installer 4.5 prerequisite with your application?
Posted 04 May, 2011 12:44:01 Top