0

The current Windows 10 upgrade 21H1 mentioned

The WMIC tool is deprecated

But to avoid manually fiddling with Task Manager I just call—actually via DOSKEY macros—in cmd.exe, like

wmic process where name="firefox.exe" CALL setpriority "below normal"

I found

powershell (Get-WmiObject Win32_process -filter 'name = "firefox.exe"' | foreach { "$($_.SetPriority(16384))"})

which is kind of a replacement, but, you see the difference which is the reason, switching to PowerShell was never an option for me.

I've seen cmdlets mentioned to replace wmic, but couldn't find how setting the process priority is meant to be done nowadays neither any good documentation by Microsoft—sigh.

4
  • Why is switching to powershell not an option? It has zero legacy quirks like cmd and is the one that's actively supported. Learning it is easier than searching to work around many cmd issues. Cmd will still be there and always be there but MS has declared it deprecated long time ago
    – phuclv
    Commented Jun 6, 2021 at 8:15
  • Thanks for hinting, and I'm aware of. Normally I would follow the official new approaches, but the only answer for my problem I found, is the given with such a syntax-horror and a "magic number" addressing a bit to set an option. This refers to the second part of my question: Where do you find a systematic, comprehensive and searchable reference to this "cmdlets" API?
    – thoku
    Commented Jun 6, 2021 at 8:57
  • The capabilities of cmd are limited so many supporting tools are required. But in PowerShell there are objects or everything, removing the need for wmic. PowerShell cmdlets are of the form Verb-Noun and typically you just need to find the noun that you want to work with. In fact Get-WmiObject is also going to be deprecated, replacing by Get-CimInstance
    – phuclv
    Commented Jun 6, 2021 at 12:47
  • 1
    Your powershell script is also using the same depreciated object as WMIC. WMIC's Process class is an alias for Win32_Process. It is classes like Win32_Process that is depreciated. Windows is changing to a technology that work better through firewalls. WMIC will continue to work for at least 20 years. Commented Jun 6, 2021 at 20:32

1 Answer 1

2

In PowerShell you deal with processes using Get-Process

Get-Process firefox |% { $_.PriorityClass = 'BelowNormal' }
2
  • Ok, this syntax is quite an improvement versus the mentioned in my question one. Also Get-Help % works. And given all the AI improvements, even the too optimistic search "docs.microsoft.com/en-us/powershell/module/…" might work in future ;)
    – thoku
    Commented Jun 6, 2021 at 17:37
  • @thoku if you search the detailed methods/properties you might not get anything because powershell help doesn't give type information. You should really search for the object you want to deal with like this. For the methods & properties you need to search in .NET: docs.microsoft.com/en-us/dotnet/api/…. There you can see the relevant System.Diagnostics.Process.PriorityClass and you can confirm that with (Get-Process powershell)[0].PriorityClass.GetType().FullName
    – phuclv
    Commented Jun 7, 2021 at 1:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .