Questions tagged [wmi]

Windows Management Instrumentation (WMI) is an API for managing the Windows operating system on local or remote computers.

4365 questions
28
votes
7 answers

Identify process using a file

I have been trying to figure out how to programmatically identify the process that has a lock on a particular file. I've searched through the Win32 API and WMI, but so far I can't find anything. I know it's possible - Sysinternals is able to list…
user47589
28
votes
8 answers

Detecting the number of processors

How do you detect the number of physical processors/cores in .net?
Peter C
  • 2,257
  • 2
  • 25
  • 28
26
votes
3 answers

How to read ManagementObject Collection in WMI using C#

I found a code on net and have been trying to get more information about mo[]. I am trying to get all the information contained in ManagementObjectCollection. Since parameter in mo is looking for an string value which I dont know, how can I get all…
Shantanu Gupta
  • 20,688
  • 54
  • 182
  • 286
25
votes
1 answer

What do Get-WMIObject \ Get-CimInstance actually do?

I have developing a new WMI instance provider and I am having a bit of trouble. I am able to register my provider successfully using regsvr32.exe. The regsvr32 application calls my implementation of DllRegisterServer and creates the following…
Code Doggo
  • 2,146
  • 6
  • 33
  • 58
25
votes
5 answers

Detect serial port insertion/removal

I am interfacing with a USB-to-serial port that can be inserted or removed at any time. I've found that I can use WMI (particularly with the use of WMI Code Creator) to query for device changes in the PC. In the generated snippet below, the…
Pat
  • 16,515
  • 15
  • 95
  • 114
25
votes
13 answers

How do I get total physical memory size using PowerShell without WMI?

I'm trying to get the physical memory size using PowerShell, but without using get-wmiobject. I have been using the following PS cmdlet to get the physical memory size, but the value changes with each new poll. (get-counter -counter…
eltaco431
  • 740
  • 2
  • 10
  • 24
24
votes
3 answers

Using clause fails to call Dispose?

I'm using Visual Studio 2010 to target .NET 4.0 Client Profile. I have a C# class to detect when a given process starts/terminates. For this the class uses a ManagementEventWatcher, which is initialised as below; query, scope and watcher are class…
groverboy
  • 1,133
  • 8
  • 20
23
votes
5 answers

Best way to programmatically configure network adapters in .NET

I have an application written in C# that needs to be able to configure the network adapters in Windows. I have this basically working through WMI, but there are a couple of things I don't like about that solution: sometimes the settings don't seem…
TimK
  • 7,438
  • 10
  • 40
  • 47
23
votes
2 answers

What Library for Powershell 6 contains the get-wmiobject command?

I am getting the following error upon attempting to use the get-WmiObject command in PowerShell (version 6): PS C:\Users\zsofi> Get-WmiObject Win32_product | select name, packagecache Get-WmiObject : The term 'Get-WmiObject' is not recognized as…
Zsofia
  • 355
  • 1
  • 2
  • 7
22
votes
7 answers

Get Screen resolution using WMI/powershell in Windows 7

I am using the following script to get screen resolution in Windows using WMI. The script works fine when the computer is in landscape mode but returns incorrect values when in portrait mode. Works properly in XP and did not try in Vista. Can anyone…
user281693
  • 615
  • 2
  • 8
  • 20
21
votes
4 answers

How to remotely control a Windows Service with ServiceController?

I'm trying to control Windows Services that are installed in a remote computer. I'm using the ServiceController class. I have this: ServiceController svc = new ServiceController("MyWindowsService", "COMPUTER_NAME"); With this, I can get the status…
Amokrane Chentir
  • 29,907
  • 37
  • 114
  • 158
20
votes
6 answers

Is there something like WMI for Linux?

I like the whole WMI concept, and I could really make use of it under Linux (in some scripts). Is there something like that for Linux systems?
Geo
  • 93,257
  • 117
  • 344
  • 520
20
votes
11 answers

NetBIOS domain of computer in PowerShell

How can I get the NetBIOS (aka 'short') domain name of the current computer from PowerShell? $ENV:USERDOMAIN displays the domain of the current user, but I want the domain that the current machine is a member of. I've discovered you can do it pretty…
David Gardiner
  • 16,892
  • 20
  • 80
  • 117
20
votes
2 answers

How can I find the Upgrade Code for an installed MSI file?

In certain cases the need to retrieve MSI upgrade codes for deployed packages can arise. Common scenarios: I took over someone else's MSI project, and I need to determine what upgrade codes were used for previous versions that are already in the…
Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
20
votes
3 answers

Recommended libraries/howtos for using WMI with java?

Hey Folks. I have a reasonably large commercial project (so for-pay licensing is always an option) that is moving into the windows space and I am planning on doing alot of polling with WMI. This is a Java 1.6 client app. Are there any good resources…
Yablargo
  • 3,520
  • 7
  • 37
  • 58