c# - Uninstall application on remote computer silently -


i developing c# program remotely uninstall application. works fine problem not list of installed products on particular selected computer.

the code listing installed product using wmi :

void listallproducts() {     try     {         connectionoptions connection = new connectionoptions();         connection.username = connect.username;         connection.password = connect.password;         connection.authority = "ntlmdomain:mshome";          managementscope scope = new managementscope("\\\\"+ connect.machinename +"\\root\\cimv2", connection);         scope.connect();          objectquery query = new objectquery("select * win32_product");          managementobjectsearcher searcher = new managementobjectsearcher(scope, query);         system.threading.thread.sleep(5000);          foreach (managementobject queryobj in searcher.get())         {             listbox4.items.add(queryobj["name"].tostring());             listbox2.items.add (queryobj["name"].tostring ());             listbox1.items.add(queryobj["identifyingnumber"].tostring());             listbox3.items.add(queryobj["version"].tostring());         }     }     catch (managementexception e)     {         messagebox.show("an error occurred while querying wmi data: " + e.message);     } } 

the code uninstalling product :

void uninstallproduct() {     try     {         connectionoptions connection = new connectionoptions();         connection.username = connect.username;         connection.password = connect.password;         connection.authority = "ntlmdomain:mshome";          managementscope scope = new managementscope("\\\\"+connect.machinename +"\\root\\cimv2", connection);         scope.connect();          managementobject classinstance = new managementobject(scope, new managementpath ("win32_product.identifyingnumber='"+listbox1.text +"',name='"+listbox2.text+"',version='"+ listbox3.text+"'"),null);          // no method in-parameters define          // execute method , obtain return values.         managementbaseobject outparams =              classinstance.invokemethod("uninstall", null, null);          // list outparams        messagebox.show ("uninstallation starts");     }     catch(managementexception err)     {         messagebox.show("an error occurred while trying execute wmi method: " + err.message);     } } 

please me out list products installed on selected machine , uninstall without consent of user of selected machine.

i believe question relates knowing applications installed on remote machine. once know that, can use code uninstall them. being case, here link article on how list of applications (with uninstall information) on remote computer:

http://mdb-blog.blogspot.com/2010/12/c-check-if-programapplication-is.html


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -