Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6193429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:07:08+00:00 2026-05-24T03:07:08+00:00

I have an installer created using Visual Studio’s Setup and Deployment that typically does

  • 0

I have an installer created using Visual Studio’s Setup and Deployment that typically does pretty good.

From time to time, one of my releases is flawed and I need a way to quickly reverse my decision to go with my fabulous upgrade.

I can create a link by including a custom class that inherits from System.Configuration.Installer or create an option in my application to uninstall itself so that I can re-install the old version using something like this:

//using System.Diagnostics;
public static void Uninstall(string productCode, string option) {
  if (!String.IsNullOrEmpty(productCode) && !String.IsNullOrEmpty(option)) {
    string path = Environment.GetFolderPath(Environment.SpecialFolder.System);
    string param1 = string.Format("{0} {1}", path, @"\msiexec.exe");
    string param2 = string.Format("{0} {1}", option, productCode);
    ProcessStartInfo psInfo = new ProcessStartInfo(param1, param2);
    // NOTE: `option` = /i to repair or remove; /x to remove only
    try {
      Process.Start(psInfo);
      return;
    } catch (Exception) { } // the uninstall failed
  }
}

So…

My question: How do I get the ProductCode for my installation?

NOTE: I understand Microsoft recommends going through the Add/Remove Programs (XP) or Programs and Features (Vista/7), but my application is going in a manufacturing environment where most PCs have these features removed (using tweak or some various tool) by our Network Administrators.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:07:10+00:00Added an answer on May 24, 2026 at 3:07 am

    An answer by Ben in the SO article In a Visual Studio setup project, How do I generate an uninstall script? got me what I needed.

    Summarized here:

    "Using Visual Studio 2005/2008, you don’t need to write any code to add a uninstall option for a Setup project (Yes I know some people can write code to do it)

    • In the Setup Project –> File System windows –> Right Click “File System on Target machine” –> add a Special Folder, select System Folder;

    • Into this system folder Add a file. Browse for msiexec.exe from local System32 folder and add it. Override default properties of this file as follows:

    Condition:=Not Installed (make sure you put ‘Not Installed’ exactly like that, same case and everything), Permanent:=True, System:=True, Transitive:=True, Vital:=False.

    • Create a new shortcut under the ‘Users Program Menu’, Set Target to the System Folder which you created in the step 1. and point it’s at the msiexec.exe. Rename the shortcut to ‘Uninstall Your Application’. Set the Arguments property to /x{space}[ProductCode].

    • Build the project, ignore warning about the fact that msiexec should be excluded, DONT exclude it or the setup project wont build.

    The ‘Not Installed’ condition and Permananet:=True ensure that the msiexec.exe is only placed into the system folder as part of the install IF it doesn’t aready exist, and it is not removed on an uninstall – therefore it;s pretty safe to ignore that warning and just go for it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an installer for MyProgram using the Visual Studio Installer (Visual Studio
I created a MSI installer by using Visual Studio 2008. I have some temp
I've been using Visual Studio's Setup & Deployment Project to create an installer for
I have created a setup project using Visual Studio 2008 . When installing on
I have created a Windows Service, and an associated installer using Visual Studio 2010.
I have a Setup project that I have build using Visual Studio 2010. The
Using Visual Studio 2010 I have created system service installer IndexingService (property ServiceName in
I have a Setup Project that I made using Visual Studio 2010. The application
I have created a very simple window service using visual studio 2010 and .NُET
I am using Visual Studio 2008 to create an MSI installer. I currently have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.