473,322 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How to uninstall a program?

I am needing to automate some installation tasks. I first need to determine
if there is already a version of a program installed. The program appears
in the Add/Remove Programs in control panel, and I know this is all stored
in the registry. But short of searching through the entire registry, I
cannot figure out how to locate the program.

I see that in the registry (for .msi) installs, stores something like:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Uninstall\{9783
3EC6-ACD7-4FD2-BFAF-B57438B55C1E}

In that key contains the Uninstall string I need. However, I do not really
want to have to search the entire registry for the product. What is that
long identifier in the name? How is it determined, etc? Or is it the same
on every machine and I can hardcode it in?

--
Adam Clauss
ca*****@tamu.edu
Nov 16 '05 #1
5 20356
Hi Adam,

Please see replies to the "Uninstall application" thread in this newsgroup.
This should answer your question.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Adam Clauss" <ca*****@tamu.edu> wrote in message
news:uV**************@TK2MSFTNGP12.phx.gbl...
I am needing to automate some installation tasks. I first need to determine if there is already a version of a program installed. The program appears
in the Add/Remove Programs in control panel, and I know this is all stored
in the registry. But short of searching through the entire registry, I
cannot figure out how to locate the program.

I see that in the registry (for .msi) installs, stores something like:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Uninstall\{9783 3EC6-ACD7-4FD2-BFAF-B57438B55C1E}

In that key contains the Uninstall string I need. However, I do not really want to have to search the entire registry for the product. What is that
long identifier in the name? How is it determined, etc? Or is it the same
on every machine and I can hardcode it in?

--
Adam Clauss
ca*****@tamu.edu


Nov 16 '05 #2
Unfortunately, that really isn't what I need.

I am not uninstalling a version of MY program, but another program. And I
am not writing an actual installer per-se, but one thing my program needs to
do to perform some tests is to remove any existing version of this other
program - so I use the suggestions mentioned in the other thread.

--
Adam Clauss
ca*****@tamu.edu
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:%2***************@TK2MSFTNGP11.phx.gbl...
Hi Adam,

Please see replies to the "Uninstall application" thread in this newsgroup. This should answer your question.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Adam Clauss" <ca*****@tamu.edu> wrote in message
news:uV**************@TK2MSFTNGP12.phx.gbl...
I am needing to automate some installation tasks. I first need to

determine
if there is already a version of a program installed. The program appears in the Add/Remove Programs in control panel, and I know this is all stored in the registry. But short of searching through the entire registry, I
cannot figure out how to locate the program.

I see that in the registry (for .msi) installs, stores something like:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Uninstall\{9783
3EC6-ACD7-4FD2-BFAF-B57438B55C1E}

In that key contains the Uninstall string I need. However, I do not

really
want to have to search the entire registry for the product. What is that long identifier in the name? How is it determined, etc? Or is it the same on every machine and I can hardcode it in?

--
Adam Clauss
ca*****@tamu.edu

Nov 16 '05 #3
Well, in this case you should really scan the registry. I remember an
uninstall command is specified for each program listed in the registry so
you can use these.
Not sure though this is the case for MSI-based installs, but these use a
uniform uninstall method so you only need a product code.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Adam Clauss" <ca*****@tamu.edu> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Unfortunately, that really isn't what I need.

I am not uninstalling a version of MY program, but another program. And I
am not writing an actual installer per-se, but one thing my program needs to do to perform some tests is to remove any existing version of this other
program - so I use the suggestions mentioned in the other thread.

--
Adam Clauss
ca*****@tamu.edu
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:%2***************@TK2MSFTNGP11.phx.gbl...
Hi Adam,

Please see replies to the "Uninstall application" thread in this

newsgroup.
This should answer your question.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Adam Clauss" <ca*****@tamu.edu> wrote in message
news:uV**************@TK2MSFTNGP12.phx.gbl...
I am needing to automate some installation tasks. I first need to

determine
if there is already a version of a program installed. The program appears in the Add/Remove Programs in control panel, and I know this is all stored in the registry. But short of searching through the entire registry, I cannot figure out how to locate the program.

I see that in the registry (for .msi) installs, stores something like:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Uninstall\{9783
3EC6-ACD7-4FD2-BFAF-B57438B55C1E}

In that key contains the Uninstall string I need. However, I do not

really
want to have to search the entire registry for the product. What is that long identifier in the name? How is it determined, etc? Or is it the same on every machine and I can hardcode it in?

--
Adam Clauss
ca*****@tamu.edu



Nov 16 '05 #4
> uniform uninstall method so you only need a product code.
Thats exactly my question :) Was wondering if there was a way to locate
this product code without scanning through the registry. A "fast" lookup
of sorts...
I've got it implemented right now as scanning, I just can't help but
thinking that it is inefficient. I figured somewhere it was stored by the
app name or something upon installation.

--
Adam Clauss
ca*****@tamu.edu
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:Ok**************@TK2MSFTNGP11.phx.gbl...
Well, in this case you should really scan the registry. I remember an
uninstall command is specified for each program listed in the registry so
you can use these.
Not sure though this is the case for MSI-based installs, but these use a
uniform uninstall method so you only need a product code.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Adam Clauss" <ca*****@tamu.edu> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Unfortunately, that really isn't what I need.

I am not uninstalling a version of MY program, but another program. And I
am not writing an actual installer per-se, but one thing my program needs
to
do to perform some tests is to remove any existing version of this other
program - so I use the suggestions mentioned in the other thread.

--
Adam Clauss
ca*****@tamu.edu
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com>
wrote in message news:%2***************@TK2MSFTNGP11.phx.gbl...
Hi Adam,

Please see replies to the "Uninstall application" thread in this

newsgroup.
This should answer your question.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Adam Clauss" <ca*****@tamu.edu> wrote in message
news:uV**************@TK2MSFTNGP12.phx.gbl...
> I am needing to automate some installation tasks. I first need to
determine
> if there is already a version of a program installed. The program

appears
> in the Add/Remove Programs in control panel, and I know this is all

stored
> in the registry. But short of searching through the entire registry, I > cannot figure out how to locate the program.
>
> I see that in the registry (for .msi) installs, stores something
like: >

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Uninstall\{9783
> 3EC6-ACD7-4FD2-BFAF-B57438B55C1E}
>
> In that key contains the Uninstall string I need. However, I do not
really
> want to have to search the entire registry for the product. What is

that
> long identifier in the name? How is it determined, etc? Or is it
the same
> on every machine and I can hardcode it in?
>
> --
> Adam Clauss
> ca*****@tamu.edu
>
>


Nov 16 '05 #5
Hi Adam,

"Adam Clauss" <ca*****@tamu.edu> wrote in message
news:uV**************@TK2MSFTNGP12.phx.gbl...
I am needing to automate some installation tasks. I first need to determine if there is already a version of a program installed.

<snip>

There are a lot of ways you can accomplish this, including using the
Microsoft Windows Installer Object Library (COM) or WMI. Since there are
already classes in .NET for WMI, I'll use that as an example. The
Win32_Product WMI class represents products installed on the machine. The
Win32_Product class has the product name, code, description, installed
location, etc., as well as methods to install, uninstall, advertise, etc the
product.

The first step is to determine the WMI "path" to the product you want to
uninstall. This routine will print out all the properties and the WMI path
for all installed products:

// need a "using System.Management;" somewhere
...
static void ListAllProducts()
{
SelectQuery allProductsQuery = new SelectQuery("Win32_Product");
ManagementObjectSearcher allProducts =
new ManagementObjectSearcher(allProductsQuery);

foreach(ManagementObject product in allProducts.Get())
{
foreach(PropertyData property in product.Properties)
{
Console.WriteLine("{0} = {1}", property.Name,
property.Value);
}
Console.WriteLine("Path = {0}", product.Path);
Console.WriteLine();
}
}

Once you have the path for the product you wish to uninstall, you can
uninstall with a method that might look like this:

static void UninstallProduct(string path)
{
ManagementObject product = new ManagementObject(path);

if ((product != null) && (product.Path.ClassName ==
"Win32_Product"))
{
object result = product.InvokeMethod("Uninstall", null);
Console.WriteLine("The Uninstall method result is {0}",
result.ToString());
}

}

A call to the UninstallProduct method above might look like this:

UninstallProduct(
"Win32_Product" +
".IdentifyingNumber=\"{F934F310-BFEB-40CA-801B-CC7136CEE35F}\""
+
",Name=\"ObjectSpaces Mapper Utility\"" +
",Version=\"1.0.0\"");

I split the path over several lines for readability. FYI, the
IdentifyingNumber property is the "Product Code". Also, the part of the path
that precedes the class name (something like "\\MachineName\root\cimv2:") is
unnecessary for anything on the local machine, so I omitted it.

Hope that helps.

Regards,
Daniel

Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sally | last post by:
I have written a gui application for windows os using Borland C++ Builder. Does anybody know how I would go about automating the installation process - for instance, I would like my executable to...
2
by: Pengyu Hong | last post by:
How to build an uninstall program? Thanks a lot, Pengyu.
2
by: Pengyu Hong | last post by:
How to build an uninstall program for an installation program I created? Thanks a lot, Pengyu.
1
by: resander | last post by:
I need to uninstall DB2 Express on a W2K Server as the evaluation period has expired to reclaim a fair chunk of disk space. The program was not in the list of the Windows Add/Remove Programs in...
1
by: =?Utf-8?B?U3RlcGhhbmU=?= | last post by:
Hi, I have develop an application in C#. I create a deployment projet to install and uninstall the application. My problem is: The application create different files who contain user's...
2
by: Jerry | last post by:
Hi I have noticed that my apps don't have an uninstall capacity in the users programs shortcuts. While users can remove the program in the control panel, add remove programs, I would like to...
4
by: chosky | last post by:
Hi Experts, I got some problems on some pcs,it may be a virus. the problem is I can't see some installed application programs and I can't remove them on ADD/REMOVE PROGRAM,and they don't have...
1
by: flamkuavos | last post by:
function NextButtonClick (...) begin if CurPageID = TestPage.ID then begin if(choose the "uninstall" Radio) ?...? ????????????? {{uninstallexe} doesnot work here} ... end else begin...
3
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post by:
Hi anyone, I have installed a winforms application vs 2005. It appears in Control Panel -Add / Remove Programs. I have another application .NET and I want uninstall the application installed...
10
by: pstve | last post by:
Hi, I've got a problem! Or two actually at this moment... I want to: - When I'm installing my program (coded in C#, installed on computer by windows installer), we can call it for "Program...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.