Detecting the number of processors

System.Environment.ProcessorCount returns the number of logical processors http://msdn.microsoft.com/en-us/library/system.environment.processorcount.aspx For physical processor count you’d probably need to use WMI – the following metadata is supported in XP/Win2k3 upwards (Functionality enabled in SP’s prior to Vista/Win2k8). Win32_ComputerSystem.NumberOfProcessors returns physical count Win32_ComputerSystem.NumberOfLogicalProcessors returns logical (duh!) Be cautious that HyperThreaded CPUs appear identical to multicore’d CPU’s yet the performance … Read more

Get the drive letter of USB drive in PowerShell

Try: gwmi win32_diskdrive | ?{$_.interfacetype -eq “USB”} | %{gwmi -Query “ASSOCIATORS OF {Win32_DiskDrive.DeviceID=`”$($_.DeviceID.replace(‘\’,’\\’))`”} WHERE AssocClass = Win32_DiskDriveToDiskPartition”} | %{gwmi -Query “ASSOCIATORS OF {Win32_DiskPartition.DeviceID=`”$($_.DeviceID)`”} WHERE AssocClass = Win32_LogicalDiskToPartition”} | %{$_.deviceid} Tested with one and more than one USB device plugged-in.

WMI “installed” query different from add/remove programs list?

I believe your syntax is using the Win32_Product Class in WMI. One cause is that this class only displays products installed using Windows Installer (See Here). The Uninstall Registry Key is your best bet. HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall UPDATE FOR COMMENTS: The Uninstall Registry Key is the standard place to list what is installed and what isn’t … Read more

How do I get information about recently connected USB device?

The Win32_DeviceChangeEvent reports just the type of event that occurred and the Time of the event (uint64, representing 100-nanosecond intervals after January 1, 1601, UTC). No that much useful if you also want to know what arrived or was removed. I suggest to use instead the WqlEventQuery class, setting its EventClassName to __InstanceOperationEvent. This system … Read more

Trying to copy file from one XP PC to another using WMI, since RPC and UNC are not available

I learned that WMI cannot create files on a remote host, and it cannot copy files over a network connection: http://msdn.microsoft.com/en-us/library/windows/desktop/aa389288%28v=vs.85%29.aspx However, it can run a cmd process. Here’s Frank White’s code in C sharp, followed by his example: https://stackoverflow.com/a/8913231/1569434 InputParameters(“CommandLine”) = “cmd /c echo myFTPCommands > c:\ftpscript.txt” You will need four things to use … Read more

How can I get the CPU temperature?

For others who may come by here, maybe take a look at : http://openhardwaremonitor.org/ Follow that link and at first you might think, “Hey, that’s an application, and that is why it was removed. The question was how to do this from C# code, not to find an application that can tell me the temperature…” … Read more

Get the serial number of USB storage devices in .Net Core 2.1

This Class performs a series of queries on the WMI Win32_DiskDrive class and its associators: Win32_DiskDriveToDiskPartition and CIM_LogicalDiskBasedOnPartition, to retrieve informations on the active USB Drives on a System (local or remote). It might seem redundant (probably because it is), since you just asked for the USB Drives Serial Number. But, you never know what … Read more