mirror of
https://github.com/actions/runner-images.git
synced 2025-12-15 06:08:07 +00:00
[Windows] Replace Win32_Product call to registry query (#5887)
* Replace Win32_Product call to registry query * Update properties
This commit is contained in:
committed by
GitHub
parent
82c8123cac
commit
70019eaa8f
@@ -277,13 +277,17 @@ function Get-GHVersion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Get-VisualCPPComponents {
|
function Get-VisualCPPComponents {
|
||||||
$vcpp = Get-CimInstance -ClassName Win32_Product -Filter "Name LIKE 'Microsoft Visual C++%'"
|
$regKeys = @(
|
||||||
$vcpp | Sort-Object Name, Version | ForEach-Object {
|
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*"
|
||||||
$isMatch = $_.Name -match "^(?<Name>Microsoft Visual C\+\+ \d{4})\s+(?<Arch>\w{3})\s+(?<Ext>.+)\s+-"
|
"HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
|
||||||
|
)
|
||||||
|
$vcpp = Get-ItemProperty -Path $regKeys | Where-Object DisplayName -like "Microsoft Visual C++*"
|
||||||
|
$vcpp | Sort-Object DisplayName, DisplayVersion | ForEach-Object {
|
||||||
|
$isMatch = $_.DisplayName -match "^(?<Name>Microsoft Visual C\+\+ \d{4})\s+(?<Arch>\w{3})\s+(?<Ext>.+)\s+-"
|
||||||
if ($isMatch) {
|
if ($isMatch) {
|
||||||
$name = '{0} {1}' -f $matches["Name"], $matches["Ext"]
|
$name = '{0} {1}' -f $matches["Name"], $matches["Ext"]
|
||||||
$arch = $matches["Arch"].ToLower()
|
$arch = $matches["Arch"].ToLower()
|
||||||
$version = $_.Version
|
$version = $_.DisplayVersion
|
||||||
[PSCustomObject]@{
|
[PSCustomObject]@{
|
||||||
Name = $name
|
Name = $name
|
||||||
Architecture = $arch
|
Architecture = $arch
|
||||||
|
|||||||
Reference in New Issue
Block a user