Skip to content

refactor: replace WMIC with PowerShell for CPU architecture detection #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 19, 2024
Merged

refactor: replace WMIC with PowerShell for CPU architecture detection #40

merged 2 commits into from
Dec 19, 2024

Conversation

tahaghafuri
Copy link
Contributor

  • Replace deprecated WMIC command with modern PowerShell
  • Use Get-CimInstance instead of WMIC to access Win32_Processor
  • Maintain compatibility with existing code by keeping same output format
  • Improve compatibility with newer Windows versions
  • No changes to core program logic

- Replace deprecated WMIC command with modern PowerShell
- Use Get-CimInstance instead of WMIC to access Win32_Processor
- Maintain compatibility with existing code by keeping same output format
- Improve compatibility with newer Windows versions
- No changes to core program logic
@tahaghafuri tahaghafuri mentioned this pull request Dec 19, 2024
@cmb69
Copy link
Member

cmb69 commented Dec 19, 2024

Thank you! So far we had no powershell requirement in the SDK, but that shouldn't be an issue, and it's certainly simpler than the JScript alternative:

var service = GetObject("winmgmts:");
var procs = service.InstancesOf("Win32_Processor");
if (procs.Count >= 1) {
    WScript.StdOut.WriteLine(procs.ItemIndex(0).Architecture);
}

or PHP:

<?php

$locator = new COM("WbemScripting.SWbemLocator");
$service = $locator->ConnectServer(".", "root\cimv2");
$procs = $service->InstancesOf("Win32_Processor");
if ($procs->Count >= 1) {
    echo $procs->ItemIndex(0)->Architecture;
}

@cmb69 cmb69 merged commit 311bc6d into php:master Dec 19, 2024
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.

2 participants