Skip to content

fix: fall back to PowerShell Get-CimInstance when wmic is unavailable on Windows 11#147

Merged
jamesmarkchan merged 3 commits intodevfrom
copilot/fix-io-exception-wmic-error
Mar 6, 2026
Merged

fix: fall back to PowerShell Get-CimInstance when wmic is unavailable on Windows 11#147
jamesmarkchan merged 3 commits intodevfrom
copilot/fix-io-exception-wmic-error

Conversation

Copy link
Contributor

Copilot AI commented Mar 6, 2026

wmic was deprecated and has been removed from some Windows 11 installations, causing a SEVERE IOException on startup when getProcessorNameWindows() tried to spawn it.

Changes — UtilOs.java

  • Split exception handling in getProcessorNameWindows(): IOException (process not found) is now caught separately from InterruptedException, logged at WARNING, and triggers a PowerShell fallback instead of swallowing the error.
  • Added getProcessorNameWindowsPowerShell(): runs the modern equivalent command when wmic is absent.
// wmic path (unchanged, still tried first for older Windows)
ProcessBuilder pb = new ProcessBuilder("wmic", "cpu", "get", "Name");

// new fallback when wmic throws IOException
ProcessBuilder pb = new ProcessBuilder(
    "powershell.exe", "-Command",
    "Get-CimInstance -Class Win32_Processor | Select-Object -ExpandProperty Name");

Systems with wmic available are unaffected. On Windows 11 without wmic, the app now retrieves the processor name cleanly instead of logging a spurious SEVERE error at launch.

Original prompt

This section details on the original issue you should resolve

<issue_title>bug: io exception running wmic 0.7.0-rc1 win11</issue_title>
<issue_description>launch error on 0.7.1-rc1

2026-03-03T19:29:38.587: Active GC: ZGC
Mar 03, 2026 7:29:38 PM jdiskmark.UtilOs getProcessorNameWindows
SEVERE: null
java.io.IOException: Cannot run program "wmic": CreateProcess error=2, The system cannot find the file specified
        at java.base/java.lang.ProcessBuilder.start(Unknown Source)
        at java.base/java.lang.ProcessBuilder.start(Unknown Source)
        at jdiskmark.UtilOs.getProcessorNameWindows(UtilOs.java:724)
        at jdiskmark.Util.getProcessorName(Util.java:267)
        at jdiskmark.App.init(App.java:218)
        at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source)
Image

program still started and was usable

Image</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…n Windows 11

Co-authored-by: jamesmarkchan <6020424+jamesmarkchan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix IO exception when running WMIC on Windows 11 fix: fall back to PowerShell Get-CimInstance when wmic is unavailable on Windows 11 Mar 6, 2026
@lane1995
Copy link

lane1995 commented Mar 6, 2026

resolves process info on system wo wmic

image image

@jamesmarkchan jamesmarkchan marked this pull request as ready for review March 6, 2026 22:56
@jamesmarkchan jamesmarkchan merged commit 758150c into dev Mar 6, 2026
1 check passed
@jamesmarkchan jamesmarkchan deleted the copilot/fix-io-exception-wmic-error branch March 9, 2026 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: io exception running wmic 0.7.0-rc1 win11

3 participants