wmi

Retrieving a descriptive value for WMI Win32_Processor.Family property instead of an index

北战南征 提交于 2019-12-24 01:13:38
问题 The below simple VBS example retrieves CPU caption, architecture and family from WMI: s = "" For Each Item In GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\Root\CIMV2").InstancesOf("Win32_Processor") s = s & "Caption = " & Item.Caption & vbCrLf s = s & "Architecture = " & Item.Architecture & vbCrLf s = s & "Family = " & Item.Family & vbCrLf Next WScript.Echo s The output for me is: Caption = Intel64 Family 6 Model 42 Stepping 7 Architecture = 9 Family = 198 What I want is to

How can I query NTFS disk quotas in C#?

*爱你&永不变心* 提交于 2019-12-24 00:27:06
问题 I need to be able to find, for all users on a given remote machine, those users' disk quotas and actual disk usage. I need to be able to do this reporting in a C# application. (Well, technically a DLL plugin for an app I've already built; but that's irrelevant here.) The remote machine is not on the same network, however, the application executing the app is able to supply the credentials. WMI is perfectly acceptable; I just cannot find (after looking for over 3 hours now) the exact

How to get WMI object from a WMI object reference

ぐ巨炮叔叔 提交于 2019-12-24 00:03:57
问题 I'm using WMI to do some Citrix work, specifically to search for a particular user to log off. First I have to enumerate an object called MetaFrame_Session, which lists current sessions, then from that I have to retrieve an object called Citrix_User, which has the user name. The Session object contains a reference to the User object, but I am not very familiar with WMI and I'm stumped as to how to get the actual object from the reference. Examples of how to do this in VBScript would be very

How can I get volume name for EFI system partition?

大城市里の小女人 提交于 2019-12-23 23:12:42
问题 I have a Windows machine with GPT drives. I have a DOS device name of EFI system partition as output from bcdedit. I want to open handle for this partition and get DOS name by QueryDosDevice() to compare with DOS name which I already have. I tried to use FindFirstVolume/FindNextVolume to find volume name to get DOS name from QueryDosDevice, but I didn't find volume for EFI system partition. WMI also doesn't have volume for this partition. How can I get volume name of EFI system partition from

WMI call to get drivers

匆匆过客 提交于 2019-12-23 19:17:56
问题 I am new using WMI. What is it? Can I use WMI call in C# for example to get list of drivers on my PC? If so, which class do I call? 回答1: To list the installed drivers you can use the Win32_PnPSignedDriver WMI class as is show on this sample. using System; using System.Collections.Generic; using System.Management; using System.Text; namespace GetWMI_Info { class Program { static void Main(string[] args) { try { string ComputerName = "localhost"; ManagementScope Scope; Scope = new

WPA does not see ETW event data, tracerpt does

北城余情 提交于 2019-12-23 18:54:44
问题 I am capturing ADO.Net diagnostics ETW, as described in Data Access Tracing in SQL Server 2008. The setup works, an ETL file is produced and I can see the ADO.Net trace if I use, say, tracerpt: System.Data, TextA, 0, 0, 0, 0, 17, 0, 0x0000000000000000, 0x000007D0, 0x00003A64, 1, , , {00000000-0000-0000-0000-000000000000}, , 131485096603462277, 450, 2400, 2, "enter_01 <prov.DbConnectionHelper.CreateDbCommand|API> 1# " System.Data, TextA, 0, 0, 0, 0, 17, 0, 0x0000000000000000, 0x000007D0,

Check whether IIS is installed or not

自作多情 提交于 2019-12-23 18:22:01
问题 I am writing a PowerShell script to host a website in IIS. I tried this script in a machine where there is no IIS installed and I got error so I want to check if IIS is installed and then I want to host a website in ISS. Below is the script I am trying but it is not working: $vm = "localhost"; $iis = Get-WmiObject Win32_Service -ComputerName $vm -Filter "name='IISADMIN'" if ($iis.State -eq "Running") { Write-Host "IIS is running on $vm" } else { Write-Host "IIS is not running on $vm" } Please

.NET - setting power options from code

拟墨画扇 提交于 2019-12-23 17:39:55
问题 I'd like to write very simple code from C# - a simple 2 button app that will allow me to change the action that is taken when the lid is closed. From "sleep" to "no action" and vice versa. I found that it somehow connected to WMI - but no actual info on how achieving this. help would be much appreciated. Thanks! 回答1: Take a look at the Windows API Code Pack, which is a wrapper around a lot of the Windows APIs. It includes the Power Management API. 回答2: This is a really old post, but

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

落爺英雄遲暮 提交于 2019-12-23 17:35:07
问题 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 Automatic mode. Here's the exception: System.Management.ManagementException: Provider load failure at System.Management.ManagementException.ThrowWithExtendedInfo

WMI Exception: “COM object that has been separated from its underlying RCW cannot be used”

允我心安 提交于 2019-12-23 16:08:31
问题 I'm subscribing to a WMI event and receiving a " COM object that has been separated from its underlying RCW cannot be used " error when my application closes. This question has been asked before, but it is quite different from my circumstances. I am calling this code from my main thread: string strComputer = @"."; ManagementScope scope = new ManagementScope(@"\\" + strComputer + @"\root\wmi"); scope.Connect(); EventQuery query = new EventQuery("Select * from MSNdis_StatusMediaDisconnect");