Windows Management Instrumentation (WMI) is an API for managing the Windows operating system on local or remote computers.
Questions tagged [wmi]
4365 questions
20
votes
3 answers
How to restart service remotely?
I can start or stop service remotely from .net project.
ConnectionOptions options = new ConnectionOptions();
options.Username = @"192.168.36.22\test";
options.Password = "test";
ManagementScope scope = new…

novicegis
- 519
- 3
- 5
- 13
19
votes
2 answers
Bootstrapping SQL Express from WiX?
I'm working on a WPF app, and using WiX as an installer.
I'd like to start using SQL Express 2012, but want to resolve installer issues first.
I'm looking for a full-up example of detecting, bootstrapping, installing, upgrading and uninstalling SQL…

RickNZ
- 18,448
- 3
- 51
- 66
19
votes
3 answers
Find USB drive letter from VID/PID (Needed for XP and higher)
So I thought I would include the final answer here so you don't have to make sense of this post. Big thanks to Simon Mourier for taking the time to figure this one out.
MY WORKING CODE
try
{
//Get a list of available…

tmwoods
- 2,353
- 7
- 28
- 55
18
votes
3 answers
WMI, negative CPU usage value and Timestamp_Sys100NS in past
I am monitoring some machines using WMI, using .NET's System.Management stuff. The query I am using is this:
SELECT Timestamp_Sys100NS, PercentProcessorTime
FROM Win32_PerfRawData_PerfOS_Processor
WHERE Name='_Total'
From that I compute the CPU…

wilx
- 17,697
- 6
- 59
- 114
18
votes
2 answers
How can I ask windows about if the RAM is running in single, dual or quad channel?
How can I detect the current RAM config? I need to ask windows about if the RAM is currently running in single, dual or quad channel.
I have searched a lot, and not found any similar questions on this or other sites, which is quite surprising to…

JohnAl
- 1,064
- 2
- 10
- 18
17
votes
3 answers
How to access WinRM in C#
I'd like to create a small application that can collect system information (Win32_blablabla) using WinRM as opposed to WMI. How can i do that from C#?
The main goal is to use WS-Man (WinRm) as opposed to DCOM (WMI).

Mark
- 5,223
- 11
- 51
- 81
17
votes
3 answers
How do I enumerate IIS websites using Powershell and find the app pool for each?
I can search for websites using:
Get-WmiObject -Namespace "root\WebAdministration" -Class Site -Authentication PacketPrivacy -ComputerName $servers
And I can list the app pools using:
Get-WmiObject -computer $servers -Namespace root\MicrosoftIISv2…

Chris Reeve
- 229
- 1
- 2
- 8
17
votes
4 answers
WIN32_Processor::Is ProcessorId Unique for all computers
I want to use some thing unique for a licensing system. i decided to use ProcessorID from Win32_Processor Management class.
I tried on two different systems with same processor type..
It shows me same processorID for both system. i am using this…

Mohsan
- 2,483
- 6
- 47
- 62
16
votes
2 answers
How to terminate process using VBScript
I have this VBScript code to terminate one process
Const strComputer = "."
Dim objWMIService, colProcessList
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set…
Mark
16
votes
1 answer
how to cleanup view model properly?
I have a view model that is used as the data source for my custom control. In the view model's constructor I set up a WMI ManagementEventWatcher and start it. My view model implements IDisposable, so I stop the watcher in the Dispose method.
When I…

akonsu
- 28,824
- 33
- 119
- 194
16
votes
5 answers
Remote WMI query slow
I'm working on a program that queries three different servers in order to get CPU and LogicalDisk information.
Each server I query returns me values in 6 to 15 seconds (depending on the server). So it takes a total of 31 seconds to get all my values…

rafatic
- 223
- 1
- 10
16
votes
4 answers
Is there a possibility to differ virtual printer from physical one?
I have a list of all printers available in WinXP. I need the code (ideally .NET) to filter out all the virtual printers from this list. Is it possible to do? I analyzed all the properties of Win32_Printer wmi class but can't see any suitable one.

user280498
- 202
- 2
- 9
16
votes
3 answers
How to identify what device was plugged into the USB slot?
I want to detect when the user plugs in or removes a USB sound card. I've managed to actually catch the event when this happens, but I can't tell what just got plugged in.
I tried an approach based on this question:
string query =
"SELECT *…

AngryHacker
- 59,598
- 102
- 325
- 594
16
votes
9 answers
Powershell Set Lid Close Action
I wanted to automate setting the action Windows 7 takes when the lid is closed on my work laptop, as this is reset via GPO every time i login.
I know that i can use the powercfg command in a batch script to achieve this:
powercfg -setacvalueindex…

CraigJPerry
- 973
- 1
- 8
- 16
16
votes
3 answers
WMI Cheatsheet?
Is there a cheatsheet available for WMI? Like what can be queried, where to query it from?

Geo
- 93,257
- 117
- 344
- 520