473,573 Members | 4,459 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_MACH INE\SOFTWARE\Mi crosoft\Windows \CurrentVersion \Uninstall\{978 3
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.ed u
Nov 16 '05 #1
5 20377
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.e du> wrote in message
news:uV******** ******@TK2MSFTN GP12.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_MACH INE\SOFTWARE\Mi crosoft\Windows \CurrentVersion \Uninstall\{978 3 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.ed u


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.ed u
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.c om> wrote
in message news:%2******** *******@TK2MSFT NGP11.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.e du> wrote in message
news:uV******** ******@TK2MSFTN GP12.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_MACH INE\SOFTWARE\Mi crosoft\Windows \CurrentVersion \Uninstall\{978 3
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.ed u

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.e du> wrote in message
news:%2******** **********@TK2M SFTNGP10.phx.gb l...
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.ed u
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.c om> wrote
in message news:%2******** *******@TK2MSFT NGP11.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.e du> wrote in message
news:uV******** ******@TK2MSFTN GP12.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_MACH INE\SOFTWARE\Mi crosoft\Windows \CurrentVersion \Uninstall\{978 3
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.ed u



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.ed u
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.c om> wrote
in message news:Ok******** ******@TK2MSFTN GP11.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.e du> wrote in message
news:%2******** **********@TK2M SFTNGP10.phx.gb l...
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.ed u
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.c om>
wrote in message news:%2******** *******@TK2MSFT NGP11.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.e du> wrote in message
news:uV******** ******@TK2MSFTN GP12.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_MACH INE\SOFTWARE\Mi crosoft\Windows \CurrentVersion \Uninstall\{978 3
> 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.ed u
>
>


Nov 16 '05 #5
Hi Adam,

"Adam Clauss" <ca*****@tamu.e du> wrote in message
news:uV******** ******@TK2MSFTN GP12.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.Manageme nt;" somewhere
...
static void ListAllProducts ()
{
SelectQuery allProductsQuer y = new SelectQuery("Wi n32_Product");
ManagementObjec tSearcher allProducts =
new ManagementObjec tSearcher(allPr oductsQuery);

foreach(Managem entObject product in allProducts.Get ())
{
foreach(Propert yData property in product.Propert ies)
{
Console.WriteLi ne("{0} = {1}", property.Name,
property.Value) ;
}
Console.WriteLi ne("Path = {0}", product.Path);
Console.WriteLi ne();
}
}

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 UninstallProduc t(string path)
{
ManagementObjec t product = new ManagementObjec t(path);

if ((product != null) && (product.Path.C lassName ==
"Win32_Product" ))
{
object result = product.InvokeM ethod("Uninstal l", null);
Console.WriteLi ne("The Uninstall method result is {0}",
result.ToString ());
}

}

A call to the UninstallProduc t method above might look like this:

UninstallProduc t(
"Win32_Prod uct" +
".IdentifyingNu mber=\"{F934F31 0-BFEB-40CA-801B-CC7136CEE35F}\" "
+
",Name=\"Object Spaces Mapper Utility\"" +
",Version=\"1.0 .0\"");

I split the path over several lines for readability. FYI, the
IdentifyingNumb er 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
2244
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 start off compressed - I would then like the installation process to 1. automatically create a new directory, uncompress the archive into the new...
2
1385
by: Pengyu Hong | last post by:
How to build an uninstall program? Thanks a lot, Pengyu.
2
4522
by: Pengyu Hong | last post by:
How to build an uninstall program for an installation program I created? Thanks a lot, Pengyu.
1
4112
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 the Control Panel, (but is for Windows XP) nor was there an Uninstall program as part of DB2 menu tree. So, I decided to try uninstall it manually...
1
2180
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 preferences. I want that the uninstall program ask to the user if he want delete or no this files.
2
2038
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 have an uninstall as an option in the program menu. I am using VS2005 and using the setup deployment project type. Thanks
4
2041
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 uninstall program too,I don't know how this happen. If anyone had any idea please let me know.
1
3192
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 Result := true end end;
3
8065
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 programatically using only the name of application that appears in Control Panel -Add /Remove Programas (the product name). Is it possible ?? Any...
10
1761
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 A", I want another program (a .exe file), "Program B", to install simultaneously without users knowledge. If I put "Registers" value to...
0
7741
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7661
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7978
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8167
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8028
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5252
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3692
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3688
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1263
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.