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 1035161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:30:13+00:00 2026-05-16T14:30:13+00:00

I am trying to write a mini w32 executable to remotely uninstall an application

  • 0

I am trying to write a mini w32 executable to remotely uninstall an application using WMI.

I can list all the installed applications using this code below but i couldnt find a way to uninstall the application remotely thru WMI and C#

I know I can do same using msiexec as a process but I wish to solve this using WMI if its possible…

Thanks,
Cem

static void RemoteUninstall(string appname)
{
    ConnectionOptions options = new ConnectionOptions();
    options.Username = "administrator";
    options.Password = "xxx";
    ManagementScope scope = new ManagementScope("\\\\192.168.10.111\\root\\cimv2", options);
    scope.Connect();


    ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_Product");

    ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
    ManagementObjectCollection queryCollection = searcher.Get();

    foreach (ManagementObject m in queryCollection)
    {
        // Display the remote computer information

        Console.WriteLine("Name : {0}", m["Name"]);

        if (m["Name"] == appname)
        {
            Console.WriteLine(appname + " found and will be uninstalled... but how");
            //need to uninstall this app...
        }
    }

}
  • 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-16T14:30:14+00:00Added an answer on May 16, 2026 at 2:30 pm

    Have a look at WMI Code Creator (a free tool from Microsoft) — it can generate WMI code for you in various languages, including C#.

    Here’s an example illustrating the Win32_Product.Uninstall method usage. You need to know the GUID, name and version of the application you want to uninstall, as they are the key properties of the Win32_Product class:

    ...
    
    ManagementObject app = 
        new ManagementObject(scope, 
        "Win32_Product.IdentifyingNumber='{99052DB7-9592-4522-A558-5417BBAD48EE}',Name='Microsoft ActiveSync',Version='4.5.5096.0'",
        null);
    
    ManagementBaseObject outParams = app.InvokeMethod("Uninstall", null);
    
    Console.WriteLine("The Uninstall method result: {0}", outParams["ReturnValue"]);
    

    If you have partial info about the application (e.g. only name or name and version), you can use a SELECT query to obtain the corresponding Win32_Process object:

    ...
    SelectQuery query = new SelectQuery("Win32_Product", "Name='Microsoft ActiveSync'");
    
    EnumerationOptions enumOptions = new EnumerationOptions();
    enumOptions.ReturnImmediately = true;
    enumOptions.Rewindable = false;
    
    ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query, options);
    
    foreach (ManagementObject app in searcher.Get())
    {
        ManagementBaseObject outParams = app.InvokeMethod("Uninstall", null);
    
        Console.WriteLine("The Uninstall method result: {0}", outParams["ReturnValue"]);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a mini file browser, where I display a list of
Trying to write a chat, like on facebook, I wondered if two clients can
ok so I am trying to dynamically create a select list using javascript, basically
Trying to write a windows speech recognition macro. Written using XML and scripting language
Trying to write Unit test for Silverlight 4.0 using Moq 4.0.10531.7 public delegate void
Trying to write a regex that can parse a full name and split it
I am trying to write a regular expression to match ruby's list and hash
I've been trying write an application which will be able to connect to a
I' trying to write an xml file from Excel VBA using Microsoft XML 6.0.
In trying to write more testable Java code, I have been using the Model-View-Presenter

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.