wmi

How to make a fast query to the file system?

I'm trying to query the filesystem on a remote machine in order to get a list of file names in a specific directory. Until now, I'm using the DirectoryInfo class in .NET. Something like this: DirectoryInfo dir = new DirectoryInfo("c:\dir"); FileInfo[] files = dir.GetFiles("*.*"); But this query answers in an average of 20/30 seconds....

How can I resolve a "Provider load failure" for WMI requests?

I'm using WMI to collect system information. It works fine on every system I've tested it on, but I have one or two users that are reporting problems. The debug logs show the WMI code is throwing a "Provider load failure" exception. I haven't been able to replicate the issue. The users have verified that the WMI service is running in...

Discovering memory type

I have been googling for awhile now and cannot discover if there is a generic way to see what type of memory (pc2700, pc3200, etc.) is used within a given workstation. Does anyone know how to extract this information? ...

how do i use another identity to execute my code in asp.net provided i have a username and password

I'm building a small web based management app. Within it I need to connect to different servers using different accounts via wmi. What I want is to tell my app: you are now run by user1, do this and this. And then I want to tell it: now you are user2, do this and this. I guess, I'm not all that clear with my question, I'll refactor it....

Remote WMI with Windows XP SP3

A fresh Windows XP SP3 install does not allow remote WMI access like Windows XP SP2 does. If I follow the steps in the "How to troubleshoot WMI-related issues in Windows XP SP2" document at http://support.microsoft.com/kb/875605 I'm unable to get SP3 to respond to a remote WMI request. Every request, even to the built-in Administrator...

Log from BIOS

I want to be able to pull in the error log from BIOS across a network. Looking at Win32_BIOS in MSDN I did not see anything defining the error log. Would love to do this in C# with WMI, but am open to suggestions. Is it possible? Edit: Win32_BIOS does not have a property (don't know if that is the right term) that contains the BIOS erro...

Powershell WMI ROOT\MicrosoftExchangev2, and WQL where usage

(PS Version 1) PS C:\> $query = 'Select * From Exchange_PublicFolder WHERE Path LIKE "/Foo%"' PS C:\> $query Select * From Exchange_PublicFolder WHERE Path LIKE "/Foo%" PS C:\> gwmi -namespace ROOT\MicrosoftExchangev2 -query $query Get-WmiObject : Provider is not capable of the attempted operation At line:1 char:5 + gwmi <<<< -namespac...

updating win32_printer management object takes so long

I use following piece of code to change printers "port" property. Problem is it executes longer than a minute. Is there a way to speed it up? Can i instantiate management object not with all properties of wmi object? And more importantly, how can i update only 1 property? Maybe i should instantiate managementobject withouth searcher? M...

Hyper-V/WMI programming Question

I've looked at several objects in the "root\virtualization" name space but I have not been able to find where Hyper-V stores the path to the config file for a given virtual machine. I need to get this file path programmatically or at least just the home path of a given virtual machine would be fine as well. What WMI object and field stor...

Recycling IIS application pool using PowerShell: "Exception calling Recycle"

It looks like a recent windows update has broken some functionality I was using to recycle IIS6 application pools, as this has been working for months up to today. Exception calling "Recycle" : "Win32: The object identifier does not representException calling "Recycle" : "Win32: The object identifier does not represent a valid object. ...

How can I tell what WQL operators are supported on a class using powershell?

So the WQL LIKE operator isn't supported on my WMI class from this question. How do I tell ahead of time, or interactively as I write, what is/is not supported? I'd like to stick with Powershell here and avoid other solutions like wmic. ...

How to create a WMI property dynamically?

Hey, I want to create properties dynamically, when the user retrieves the instances of my class. Implementation in c++, but Put can't create properties on the fly. Can someone point me to the function(s) I need to use to "fill" a empty class on the fly with properties and values. Ciao Ephraim ...

Detecting USB drive insertion and removal using windows service and c#

Looking into possibility of making an USB distributed application that will autostart on insertion of an USB stick and shutdown when removing the stick Will use .Net and C#. Looking for suggestion how to approach this using C#? Update: Two possible solutions implementing this as a service. - override WndProc or - using WMI query with ...

WMI Queries in C?

Is it possible to issue WMI WQL queries in plain C? And if yes, how? ...

How can I change the username/password of an ApplicationPool in IIS from C#?

I am using the code below to create a new application pool in the Installer class of my application: private static void CreateAppPool(string serverName, string appPoolName) { // metabasePath is of the form "IIS://<servername>/W3SVC/AppPools" // for example "IIS://localhost/W3SVC/AppPools" // appPoolName is of the form...

How can I look up IIS site id in C#?

I am writing an installer class for my web service. In many cases when I use WMI (e.g. when creating virtual directories) I have to know the siteId to provide the correct metabasePath to the site, e.g.: metabasePath is of the form "IIS://<servername>/<service>/<siteID>/Root[/<vdir>]" for example "IIS://localhost/W3SVC/1/Root" How can...

WMI erroring out after a while

I have an interesting/annoying problem with some VBScripts running on Windows 2003 Server (they run fine on XP). The scripts basically periodically call WMI objects to extract performance information and write it to a log file. It's started by Scheduled Tasks at 12:05 each morning and runs until midnight (or would if it didn't keep cras...

VB Script GetObject method error...Help please WMI

Hi below is the code, at this point i get error message: Set objWMI = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2") Error: Invalid procedure call or Argument: "GetObject" Code: 800A005 Source: Microsoft VBScript Runtime error ...

How can I delete IIS objects from c#?

I need to delete a Virtual Directory and Application pool from .NET as part of my uninstall method. I found the following code on the web somewhere: private static void DeleteTree(string metabasePath) { // metabasePath is of the form "IIS://<servername>/<path>" // for example "IIS://localhost/W3SVC/1/Root/MyVDir"...

WMI "installed" query different from add/remove programs list?

Trying to use WMI to obtain a list of installed programs for Windows XP. Using wmic, I tried: C:\Documents and Settings\romandas>wmic wmic:root\cli>/output:c:\ProgramList.txt product get name,version and I get a listing of many of the installed programs, but after scrubbing this list against what "Add/Remove Programs" displays, I se...