It is currently June 16th, 2021, 11:02 am

WMIC is going away!

Tips and Tricks from the Rainmeter Community
User avatar
jsmorley
Developer
Posts: 21758
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

WMIC is going away!

Post by jsmorley »

Microsoft will very soon be deprecating / removing the command-line WMIC tool that let you query information about your system in a cmd.exe command window.

If you are using skins that made use of the WMIC tool to retrieve information, you should very quickly change them to use the built-in PowerShell commandlets that support accessing this kind of information using CimInstance.

https://docs.microsoft.com/en-us/powershell/scripting/learn/ps101/07-working-with-wmi?view=powershell-7.1

https://powershell.one/wmi/root/cimv2

So for instance:

Old method:

Code: Select all

[MeasureGetAdapter]
Measure=Plugin
Plugin=RunCommand
Program=WMIC
Parameter=path win32_VideoController get name
OutputType=ANSI
RegExpSubstitute=1
Substitute="(?siU)^Name.*([\S].*)$":"\1","#CRLF#":""
New method:

Code: Select all

[MeasureGetAdapter]
Measure=Plugin
Plugin=RunCommand
Program=PowerShell
Parameter=(Get-CimInstance -ClassName win32_VideoController -Property Name).Name
OutputType=ANSI
So in a skin like this:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
OnRefreshAction=[!CommandMeasure MeasureGetAdapter "Run"]

[Metadata]
Name=GetGraphicsAdapterPS
Author=JSMorley
Information=Retreives and displays the name of the primary display adapter in Windows using PowerShell and WMI
Version=May 21, 2021

[MeasureGetAdapter]
Measure=Plugin
Plugin=RunCommand
Program=PowerShell
Parameter=(Get-CimInstance -ClassName win32_VideoController -Property Name).Name
OutputType=ANSI

[MeterDisplay]
Meter=String
MeasureName=MeasureGetAdapter
FontSize=10
FontColor=255,255,255,255
FontWeight=600
Antialias=1

1.png
You do not have the required permissions to view the files attached to this post.
User avatar
SilverAzide
Rainmeter Sage
Posts: 1290
Joined: March 23rd, 2015, 5:26 pm

Re: WMIC is going away!

Post by SilverAzide »

:ThinkingBig This gets me to wondering... it would be nice to have a generic plugin that could query any WMI class and return a value, or perhaps a list of values. It's pretty simple matter to query these classes, and there's a ton of useful info there... The ROI is questionable, since features already in Rainmeter can get you about 99% of everything most users want.
Gadgets Wiki GitHub More Gadgets...