wmi

Has anyone successfully used the WMI Win32_PatchPackage class? (C#)

安稳与你 提交于 2019-12-24 16:34:40
问题 According to sources here and here, this class should give me a nice and human-readable list of patches applied to Windows. What I want is a list of KB patches applied to a remote machine. ManagementScope scope; ConnectionOptions options = new ConnectionOptions(); options.Username = tbUsername.Text; options.Password = tbPassword.Password; options.Authority = String.Format("ntlmdomain:{0}", tbDomain.Text); scope = new ManagementScope(String.Format("\\\\{0}\\root\\cimv2", tbHost.Text), options)

The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) when connecting to remote computer

不想你离开。 提交于 2019-12-24 15:15:20
问题 I try to connect remote computer by using winforms c#. My Code: private void Form1_Load(object sender, EventArgs e) { var connection = new ConnectionOptions(); connection.Username = "xx"; connection.Password = "xx"; var scope = new ManagementScope("\\\\111.111.111.22:6000\\root\\CIMV2", connection); scope.Connect(); // Exception occurs here.. } I get below Error in line scope.Connect(); Error: An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in System

Set WMI permissions for 'Domain users'

血红的双手。 提交于 2019-12-24 13:45:20
问题 I've created two functions in PowerShell, one that creates the Namespace ROOT\CustomCMClasses and one that creates the class Test . This piece works fine: Param ( $Namespace = 'CustomCMClasses', $Class = 'Test' ) Function New-WMINamespaceHC{ if (Get-WmiObject -Namespace 'root' -Class '__NAMESPACE' | Where-Object {$_.Name -eq $Namespace}) { Write-Verbose "WMI Namespace 'root\$Namespace' exists" } else { Write-Verbose "Create WMI namespace 'root\$Namespace'" $Ns = [WMICLASS]'root:__Namespace'

Why Win32_ProcessStopTrace-Events arrive, but Win32_ProcessStartTrace doesn't?

半世苍凉 提交于 2019-12-24 12:35:12
问题 Consider following code: using (ManagementEventWatcher watcher = new ManagementEventWatcher("select * from Win32_ProcessStopTrace")) { watcher.EventArrived += (object sender, EventArrivedEventArgs e) => { Console.WriteLine("{0} stopped", (string)e.NewEvent["ProcessName"]); }; watcher.Start(); while (!Console.KeyAvailable) System.Threading.Thread.Sleep(50); watcher.Stop(); } When I run this code (as admin), it notifies me as soon as I close any other application. First: When using Win32

How to extract a particular attribute from instance of Win32_PnPEntity?

拥有回忆 提交于 2019-12-24 12:34:39
问题 def getPnpDeviceInfo(): c = wmi.WMI() wql = "SELECT * FROM Win32_PnPEntity WHERE Manufacturer != 'Microsoft' AND NOT PNPDeviceID LIKE 'ROOT\\%'" print ("All physical PNP devices") for J in c.query(wql): print(J) This function (the query) typically returns all physical PNP devices, here is an output sample : instance of Win32_PnPEntity { Caption = "ACPI Lid"; ClassGuid = "{4d36e97d-e325-11ce-bfc1-08002be10318}"; ConfigManagerErrorCode = 0; ConfigManagerUserConfig = FALSE; CreationClassName =

Use WMI to get current Windows username in VBA

跟風遠走 提交于 2019-12-24 12:06:06
问题 I was wondering if there was a simple way to use WMI to get you the current windows user name with domain. The Windows API call just gets you the short username, so you end up doing another call for the domain name. I have some code, but I get an automation error. Any ideas? I think I'm on the right path, but I am a little new to WMI. Function GetFullName() As String Dim computer As String computer = "." Dim objWMIService, colProcessList As Object Set objWMIService = GetObject("winmgmts:\\" &

Get WMI CPU Values using Perl

痞子三分冷 提交于 2019-12-24 11:49:19
问题 I'm Trying go GET CPU values using WMI classes but with no lucky. With the class Win32_PerfFormattedData_PerfOS_Processor , I'm always getting the same values they don't change... With the WMI class Win32_PerfRawData_PerfOS_Processor , the value of PercentProcessorTime is equal to PercentProcessorTime , something is wrong. #!/usr/bin/perl -w use strict; use warnings; use Win32::OLE; use Data::Dumper; my $class = "Win32_PerfFormattedData_PerfOS_Processor"; my $key = 'Name'; my @properties = qw

WMI defrag method not found in C#

試著忘記壹切 提交于 2019-12-24 10:54:26
问题 I'm trying to use WMI to defrag my C: Drive. I'm running Windows 7 Pro x64. Console.WriteLine(SMARTManager.Instance.SMARTHDD.Defrag("C:", ref ERR)); Function: public string Defrag(string a_DriveName, ref string ERR) { try { ManagementObject classInstance = new ManagementObject("root\\CIMV2", String.Format("Win32_Volume.DeviceID='{0}'", a_DriveName), null); // Obtain in-parameters for the method ManagementBaseObject inParams = classInstance.GetMethodParameters("Defrag"); // Add the input

Check for daylight saving time with WMI on Vista/Win7

ぐ巨炮叔叔 提交于 2019-12-24 08:47:14
问题 How do I find out if the computer I'm on has daylight saving time in effect? (preferably using WMI) According to this article at TechNet, I could query SELECT DaylightInEffect FROM Win32_ComputerSystem , but the property DaylightInEffect is not supported on Vista or Win7. As my program will run on various systems (XP, Vista, 7), I would appreciate some portable way of finding out. 回答1: The documented supported OS list is not accurate, this works fine on Win7 when I try it. I can't think of

WMI error with a simple query in C#

时光怂恿深爱的人放手 提交于 2019-12-24 08:39:48
问题 I am trying to use this code on Windows 2000: foreach (Process p in Process.GetProcesses()) { if (p.MainModule.FileName.EndsWith("calc.exe")) { using (ManagementObjectSearcher mos = new ManagementObjectSearcher( "SELECT CommandLine,ExecutablePath FROM Win32_Process WHERE ProcessId=" + p.Id.ToString())) { using (ManagementObjectCollection moc = mos.Get()) { foreach (ManagementObject mo in moc) { MessageBox.Show((string)mo["CommandLine"]); return; } } } } } This works on Windows XP and higher,