|
Personnaly, I prefer to use the /x argument with Msiexec ... /i is for installing and when the software is already installed, it shows a dialog proposing to repair or uninstall your product. With the /x, it only asks for a confirmation.
See Msiexec arguments list[^] for more details.
|
|
|
|
|
:|The code don't work in web aplications.
Then, i create a new console project called UninstallProgram and add a class called UninstallClassP. After i program this code:
public static void Main(string[] args)
{
string[] arguments = Environment.GetCommandLineArgs();
foreach(string argument in arguments)
{
if (argument.Split('=')[0].ToLower() == "/u")
{
string guid = argument.Split('=')[1];
string path = Environment.GetFolderPath(Environment.SpecialFolder.System);
System.Diagnostics.ProcessStartInfo si = new System.Diagnostics.ProcessStartInfo(path + @"\msiexec.exe", "/x " + guid);
si.UseShellExecute = false;
System.Diagnostics.Process.Start(si);
//Close();
//Application.Exit();
}
}
}
In my websetup project in FileSystem editor i add a primary output from UninstallProgram and I create a shortcut from this primary output.
After i select create a special Folder "User's Program Menu" and paste in it the shortuct created in previous step.
That's all.
Victor Velepucha.
MCSD.NET
|
|
|
|
|
... if you're designing for winxp logo compliance you shouldn't put the uninstall program on the start menu because add/remove in the control panel is where it's supposed to be cleaned up. IT's not an requirement at the moment, it's listed as a best practice in the section of planned future requirements.
|
|
|
|
|
This code does not eliminate the add/remove icon in control panel. It simply adds another way to uninstall the app. IIRC, logo compliance requires the uninstall to be in the control panel, but does not require it to be absent from the start menu.
|
|
|
|
|
You're right that it's not forbidden yet, but it's listed as a best practice in the section that's used to preview planned additions to the next version of the guide, and longhorn will be out before too much longer.
|
|
|
|
|
That's what I was just going to say ! The very first thought I had, even before I'd finished to read the title : "Isn't it against the Designed For XP logo ?"
Michael CARBENAY
Creo Ignem
|
|
|
|
|
I dont see anywhere that Windows XP logo compliance forbids a start menu uninstall entry, as long as the uninstall is ALSO in the control panel.
Regardless, the reasons why you might want to do this in addition to the normal add/remove icon is that A) many users expect to see it, and B) the uninstall process is far quicker on most machines in operation (most of which are 3-5 years old) than wading though control panel icons and waiting for the add/remove programs list to populate and calculate disk space usage for every application in its list before ever giving you the opportunity to uninstall.
Further, when doing support, it is far easier to instruct a computer novice to go to the uninstall entry right next to the application that they are familiar with in order to uninstall the application than into the control panel which they might never even known exists.
|
|
|
|
|
It's not a requirement, but it's in the Future requirement sections. F1.1 precisely states :
• Do not place shortcuts to remove the application in the Start menu. It is not needed because your application’s uninstaller is in the Add or Remove Programs Control Panel item.
but you're right, there's no need for doing so at this point. I suppose that "designed for hasta-la-vista baby" (oooopss...) will have this as a requirement.
Besides I have done enough user support to know that, basically, an untrained user will already have gone to the program files and deleted the folder (thanks to his son, nephew or any adolescent kid that he knows and who have said so) by the time he thinks about calling support.
That said, I still strongly find that your tip about how to do it is good, it's just that it should be pointed out that, if you're an hardcore microsoft-er, you should avoid making things that you'll have to remove in future version of windows and obviously things that Office don't do (ok, let's say that you shouldn't do a such componentized install : it makes the life of network-installed-office-user such a pain, but the rest sounds sensible).;P
Michael CARBENAY
Creo Ignem
|
|
|
|
|
I think we are in agreement here. I offer the opportunity for those, like me, who wanted it form the beginning. If it came down to being actually against the logo compliance, I would still do it for the sole reason that many of my users expect to see it.
|
|
|
|
|
|
i tried the code (converted to c#) but it got strange reaction.
when i press the uninstall icon the application runs an the uninstall dialog too.
when i press Remove it stuck with error about the application that holds my resources (that i want to uninstall) -
so i need to shutdown the application and press Retry.
isn't there a way to make uninstall without showing the Application in the background?
i tried the code before the "InitializeComponents" and after that before the "Application.Run(new MainForm());" in the static method "Main".
any suggestions or other ways to make uninstall?
Avi.
|
|
|
|
|
In VB I saw this effect only if I called Process.Start after InitializeComponent. This might be a difference between how VB and C# handles initializaion. I will check into this and see if I can determine the precise cause, and a solution.
|
|
|
|
|
Okay, try this... Change the code in the "/u" if block to the following:
_uninstallGuid = argument.Split("=")(1)
AddHandler Application.ApplicationExit, AddressOf UninstallOnApplicationExit
Application.Exit()
End
... And add the following code:
Private _uninstallGuid As String
Sub UninstallOnApplicationExit(ByVal sender As Object, ByVal e As EventArgs)
Dim path As String = _
Environment.GetFolderPath(Environment.SpecialFolder.System)
Dim si As New ProcessStartInfo(path & "\msiexec.exe", "/i " & _uninstallGuid)
Process.Start(si)
End Sub
You will have to convert it to C#, but this might work better for you. If it works, let me know and I will update the article.
It is also possible that .NET is not completely exiting because it still hasn't disposed fo all resources. If that is happening you can try explicitly calling for garbage collection and then calling Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.System & "\msiexec.exe", "/i " & _uninstallGuid) without creating a path String or si ProcessStartInfo. This way the minimum number of objects will be left to be cleaned up when the application tries to exit.
|
|
|
|
|
well, i tried your new code but with no success,
the application is Up and just when i exit it the uninstall program runs.
well, i'll try to find out other way,
i'll let you know if i'll come into one.
thanks man,
Avi.
|
|
|
|
|
To avoid opening your app form, move your uninstallation code to the Main()
[STAThread]
static void Main()
{
string[] args=Environment.GetCommandLineArgs();
foreach(string arg in args)
{
if(arg.Split('=')[0].ToLower()=="/u")
{
string guid=arg.Split('=')[1];
string path=Environment.GetFolderPath(System.Environment.SpecialFolder.System);
string str=path+"\\msiexec.exe";
ProcessStartInfo pi=new ProcessStartInfo(str);
pi.Arguments="/i "+ guid;
pi.UseShellExecute=false;
Process.Start(pi);
return;
}
}
Application.EnableVisualStyles();
Application.Run(new MyForm());
}
Regards,
John
|
|
|
|
|
is this the only code that i need to have or should i had some events also (like in the other responsed before),
because it still not working
|
|
|
|
|
Hi,
It's the only code you need. It works fine with my apps. please make sure you follow the instructions in this article.
1. create a shortcut of Primary output, and move it to User's Programs Menu, and rename it as Uninstall.
2. Select the renamed item (uninstall), in the property window, set Argument to /u=[ProductCode]
3. Add the code I gave to you in the Main().
Once you installed your app, then you can easily uninstall it.
A simple way to debug your code:
In your setup project property window, copy your ProductCode, for my app it is
{1BC5D02E-7390-4923-8114-E468E35D5468}
set your project commandline argument to /u={1BC5D02E-7390-4923-8114-E468E35D5468}
then you can step into the code in Main() and find where the problem is.
Or simply run from command prompt:
msiexec.exe /i {1BC5D02E-7390-4923-8114-E468E35D5468}
to see if it works on your machine.
Good Luck!
John
|
|
|
|
|
it worked!
the mistake was the i wrote in the Argument "/u=[ProductCode]" and i thought that the [ProductCode] is automaticlly written in the runtime.
well, it works now,
just need to get UnInstall icon.
thanks!
Avi,;)
|
|
|
|
|
Actually, yes. If you put the "/u=[ProductCode]" as is as the command line argument to the uninstall start menu entry in the deployment project, then the MSI package will automatically replace "[ProductCode]" with the products uninstall GUID.
If it didn't work before, they you might have spelled it incorrectly, or with the wrong capitalizaion. Since msiexec is written in C, MSI properties such as ProductCode are fully case sensitive. In addition, you need to include the square brackets [] around the name ProductCode, with no additional spaces or the MSI package will not see it as a variable property which needs to be replaced ar run-time.
|
|
|
|
|
I'm having similar trouble in a c# app.
Tried embedding the uninstall code in the main form and depending on where I put it I either get:
* A working uninstall that still launches the app.
* An uninstall that crumps halfway through. Shortcuts disappear from the desktop, start menu, and quick launch, but the program files folder remains and if I go to add/remove programs the app is still there (and can be removed successfully there).
* An uninstall that immediately crumps on launch. Kicks up that helpful "wouldn't you like to send this information to Microsoft but damned little information for you is actually in it" message.
Finally separated the uninstall code into a separate console app and added that exe to the deployment package. Using the same argument structure for convenience. Works.
Note that this one uninstalls without prompts but does show a progress bar. Look up the command line arguments for msiexec.exe if you want this otherwise.
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace uninstall
{
class uninstall
{
static void Main(string[] args)
{
string[] arguments = Environment.GetCommandLineArgs();
foreach (string arg in arguments)
{
if (arg.Split('=')[0].ToLower() == "/u")
{
string guid = arg.Split('=')[1];
string path = Environment.GetFolderPath(System.Environment.SpecialFolder.System);
string str = path + "\\msiexec.exe";
ProcessStartInfo pi = new ProcessStartInfo(str);
pi.Arguments = "/passive /uninstall " + guid;
pi.UseShellExecute = false;
Process.Start(pi);
}
}
}
}
}
|
|
|
|