Entries from August 2007 ↓

Using WMIC For Gathering System Info

WMIC is a command line interface to WMI (Windows Management Instrumentation). While it has many uses, I find it especially useful for querying certain system parameters.

Processor:

C:\>wmic cpu get Name

Name
Intel(R) Pentium(R) M processor 1.80GHz
C:\>wmic cpu get NumberOfCores, NumberOfLogicalProcessors

NumberOfCores  NumberOfLogicalProcessors
1              1

The NumberOfCores and NumberOfLogicalProcessors properties are new to Windows Vista. NumberOfLogicalProcessor refers to the number of hyperthreading execution units that a processor has. NumberOfCores, to state the obvious, gets you the number of cores that a processor has.

Operating System:

C:\>wmic os get Name

Name
Microsoftr Windows VistaT Ultimate |C:\Windows|\Device\Harddisk0\Partition1
C:\>wmic os get BuildNumber, BuildType, Version

BuildNumber  BuildType            Version
6000         Multiprocessor Free  6.0.6000
C:\>wmic os get ServicePackMajorVersion, ServicePackMinorVersion

ServicePackMajorVersion  ServicePackMinorVersion
0                        0
C:\>wmic os get OperatingSystemSKU
OperatingSystemSKU
1

The OperatingSystemSKU property is new to Windows Vista. A value of 1 means that you are running the Ultimate edition. Other values and their corresponding SKU names can be found on the Win32_OperatingSystem documentation page.

Finally, Windows Vista introduces the concept of Windows Experience Index that allows you to measure your PC’s performance. Your computer’s Windows Experience Index (WEI) score can be queried from command line. First we find out if the WEI score for your computer is still valid:

C:\>wmic path Win32_WinSAT get WinSATAssessmentState

WinSATAssessmentState
1

A value of 1 for the property WinSATAssessmentState means that we have the correct, latest value of the WEI score available. A value other than 1 means that the score is either unknown or needs to be recomputed to be coherent with a hardware change made to the machine. Here is how you can get to the WEI scores:

C:\>wmic path Win32_WinSAT get CPUScore, D3DScore, DIskScore, GraphicsScore, MemoryScore, WinSPRLevel

CPUScore  D3DScore  DiskScore  GraphicsScore  MemoryScore WinSPRLevel
3.7       2.5       3.8        2              4.1         2

Cleaning Hard Disks

I’ve been exceptionally unlucky with hard disks over last few days – to the point that I was beginning to wonder if I was exuding some kind of magnetic force field. Fortunately, the latest replacement from Toshiba seems to be doing fine and looks like the hard-disk I had on loan from an old PC will have to go back.

I was looking for ways to wipe data off the old disk beyond just formatting it, when I stumbled upon DiskPart’s clean command. Here is how you’ll do it (assuming the disk you are trying to clean is #1).

C:\>DiskPart

DISKPART> select disk 1

Disk 1 is now the selected disk.

DISKPART> list partition

  Partition ###  Type              Size     Offset
  -------------  ----------------  -------  -------
* Partition 1    Primary            241 MB      0 B

DISKPART> clean all

DiskPart succeeded in cleaning the disk.

Firstly DiskPart always assumes you know what you are doing. It will not prompt you for confirmations. Unlike some of the other disk management tools (linux’s fdisk comes to mind), there is no “commit phase” where you write the changes you made to the disk. All changes are made live to the disk. Be extremely careful with this tool.

This technique works for external disks as well as for memory cards/sticks. In fact the output above is from an actual session with my 256 MB SD card connected via a USB card reader.

The list partition command has nothing to do with disk clean-up. It is merely a way to make sure that I have the correct disk selected.

The clean command simply zeros out the master boot record, while clean all zeros out every sector on the disk.

Surely a tool as powerful as this deserves a KB, and gets one too!.

If you need more rigorous cleaning than what DiskPart gives, you’ll need to look at external tools such as PDWipe.