fix(template): skip KMS activation if Windows already activated
This commit is contained in:
@@ -347,6 +347,13 @@ Write-Step "Windows KMS activation"
|
|||||||
$cscript = "$env:SystemRoot\System32\cscript.exe"
|
$cscript = "$env:SystemRoot\System32\cscript.exe"
|
||||||
$slmgr = "$env:SystemRoot\System32\slmgr.vbs"
|
$slmgr = "$env:SystemRoot\System32\slmgr.vbs"
|
||||||
|
|
||||||
|
# Check current activation status before doing anything
|
||||||
|
$licOk = Get-CimInstance SoftwareLicensingProduct -Filter "Name like 'Windows%'" -ErrorAction SilentlyContinue |
|
||||||
|
Where-Object { $_.LicenseStatus -eq 1 }
|
||||||
|
|
||||||
|
if ($licOk) {
|
||||||
|
Write-Host " [OK] Windows already activated (LicenseStatus=1) — skipping KMS activation." -ForegroundColor Green
|
||||||
|
} else {
|
||||||
Write-Host "Setting KMS server..."
|
Write-Host "Setting KMS server..."
|
||||||
& $cscript //NoLogo $slmgr /skms kms8.msguides.com 2>&1 | Write-Host
|
& $cscript //NoLogo $slmgr /skms kms8.msguides.com 2>&1 | Write-Host
|
||||||
|
|
||||||
@@ -361,6 +368,7 @@ if ($licOk) {
|
|||||||
} else {
|
} else {
|
||||||
Write-Warning " [WARN] Windows not activated — /ato may have failed or KMS server unreachable. CI builds will work in the grace period."
|
Write-Warning " [WARN] Windows not activated — /ato may have failed or KMS server unreachable. CI builds will work in the grace period."
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# ── Step 4: Build user account ───────────────────────────────────────────────
|
# ── Step 4: Build user account ───────────────────────────────────────────────
|
||||||
Write-Step "Creating build user account: $BuildUsername"
|
Write-Step "Creating build user account: $BuildUsername"
|
||||||
|
|||||||
@@ -347,6 +347,13 @@ Write-Step "Windows KMS activation"
|
|||||||
$cscript = "$env:SystemRoot\System32\cscript.exe"
|
$cscript = "$env:SystemRoot\System32\cscript.exe"
|
||||||
$slmgr = "$env:SystemRoot\System32\slmgr.vbs"
|
$slmgr = "$env:SystemRoot\System32\slmgr.vbs"
|
||||||
|
|
||||||
|
# Check current activation status before doing anything
|
||||||
|
$licOk = Get-CimInstance SoftwareLicensingProduct -Filter "Name like 'Windows%'" -ErrorAction SilentlyContinue |
|
||||||
|
Where-Object { $_.LicenseStatus -eq 1 }
|
||||||
|
|
||||||
|
if ($licOk) {
|
||||||
|
Write-Host " [OK] Windows already activated (LicenseStatus=1) — skipping KMS activation." -ForegroundColor Green
|
||||||
|
} else {
|
||||||
Write-Host "Setting KMS server..."
|
Write-Host "Setting KMS server..."
|
||||||
& $cscript //NoLogo $slmgr /skms kms8.msguides.com 2>&1 | Write-Host
|
& $cscript //NoLogo $slmgr /skms kms8.msguides.com 2>&1 | Write-Host
|
||||||
|
|
||||||
@@ -361,6 +368,7 @@ if ($licOk) {
|
|||||||
} else {
|
} else {
|
||||||
Write-Warning " [WARN] Windows not activated — /ato may have failed or KMS server unreachable. CI builds will work in the grace period."
|
Write-Warning " [WARN] Windows not activated — /ato may have failed or KMS server unreachable. CI builds will work in the grace period."
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# ── Step 4: Build user account ───────────────────────────────────────────────
|
# ── Step 4: Build user account ───────────────────────────────────────────────
|
||||||
Write-Step "Creating build user account: $BuildUsername"
|
Write-Step "Creating build user account: $BuildUsername"
|
||||||
|
|||||||
Reference in New Issue
Block a user