473,320 Members | 1,939 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,320 software developers and data experts.

WMI not responds

Hi mister,

I need use WMI for get list of applications installed.
This is my code:

ManagementObjectSearcher query = null;
ManagementObjectCollection queryAPPSCollection = null;
//ManagementScope msc = new ManagementScope("\\" + computer_name
+ @"\root\cimv2");
ManagementScope msc = new ManagementScope("root\\CIMV2");
string query_command = "SELECT * FROM Win32_Product";
SelectQuery select_query = new SelectQuery(query_command);
query = new ManagementObjectSearcher(msc, select_query);
queryAPPSCollection = query.Get();
foreach (ManagementObject mo in queryAPPSCollection)
{

when it executes foreach the application not responds !!!

Any solution about it ?? please...regards...

--
http://www.alhambra-eidos.es/web2005/index.html
www.kiquenet.com/churrosoft
http://www.setbb.com/putainformatica...opic.php?p=843
www.trabajobasura.com/solusoft

Oct 1 '08 #1
1 1652
Alhambra Eidos Desarrollo wrote:
Hi mister,

I need use WMI for get list of applications installed.
This is my code:

ManagementObjectSearcher query = null;
ManagementObjectCollection queryAPPSCollection = null;
//ManagementScope msc = new ManagementScope("\\" +
computer_name + @"\root\cimv2");
ManagementScope msc = new ManagementScope("root\\CIMV2");
string query_command = "SELECT * FROM Win32_Product";
SelectQuery select_query = new SelectQuery(query_command);
query = new ManagementObjectSearcher(msc, select_query);
queryAPPSCollection = query.Get();
foreach (ManagementObject mo in queryAPPSCollection)
{

when it executes foreach the application not responds !!!

Any solution about it ?? please...regards...
Hi Alhambra,

Getting the installed apps takes a long time (on my fast machine with
only a moderate amount of apps installed about 120 seconds or so) I
think that probably you are not hung, just waiting a long time.
Here is a Powershell version of the same thing, again, it takes ages on
my machine and does appear hung for a couple minutes.

Runspace rs = RunspaceFactory.CreateRunspace();
rs.Open();
Pipeline pl = rs.CreatePipeline();
pl.Commands.AddScript("get-wmiobject win32_Product");

StringBuilder sb = new StringBuilder();
Collection<PSObjectlist = pl.Invoke();
rs.Close();
foreach (PSObject obj in list)
{
var app = new
{
Name = obj.Properties["Name"].Value as string,
Vendor = obj.Properties["Vendor"].Value as string,
Version = obj.Properties["Version"].Value,
Caption = obj.Properties["Caption"].Value as string
};
sb.AppendLine(string.Format("{0,-200}{1}",app.Name, app.Version !=
null ? app.Version.ToString() : "[null]"));
}
textBox1.Text = sb.ToString();

Regards Tim.
Oct 1 '08 #2

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

Similar topics

0
by: Dave | last post by:
KeyDown and KeyPress events catch Page Up/Down keystrokes too late so I can't stop program from acting on them in the way it does (up selects a cell in the uppermost row and down selects a cell in...
6
by: Hal Vaughan | last post by:
I'm using KDE on Linux, with Konqueror as the testing browser for this project. I've recently upgraded, so I realize some of the bugs I'm dealing with may or may not be my program, and could also...
2
by: James | last post by:
We have two Windows Server 2003 Web servers behind an F5 load balancer("server1" and "server2"). Application requests are via the dns name of this "cluster" ("servervip"). The application needs...
16
by: who be dat? | last post by:
Consider the following code which enables multithreading in an ASP.Net application I'm writing: Code in global.asx Application_start subroutine, Threadnotify is declared Globally as a new thread...
10
by: mttc | last post by:
I read articles that suggest preventing delete by throwing Exception from RowDeleting Event. I not understand where I can catch this Error?
0
by: Jim Hubbard | last post by:
(I am quoting liberally from "Microsoft walks VB tight rope" at http://news.com.com/Microsoft+walks+VB+tight+rope+-+page+2/2100-1007_3-5620821-2.html?tag=st.num below, so read it first if you want)...
8
by: pt36 | last post by:
I have two pages one.html two.html page one.html have a form named form1 and a textarea named text1 man one write in the textarea text 1 page two.html have a form named form2 and a...
10
by: Bill Bell | last post by:
The subject line is a little too general. I would like you to tell me about scripts that can receive email messages and call other scripts depending on the content of these messages. Thanks!
2
by: BillE | last post by:
Using vb.net 2008 windows forms. How can a form which has been closed and disposed still attempt to handle a custom event? I have a form which inherits from a base form class. The base...
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: 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)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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.