mirror of
https://github.com/actions/runner-images.git
synced 2025-12-20 06:35:47 +00:00
Fix error "NoProcessFoundForGivenName" when running Disable-InternetExplorerESC
The error happens because we try to stop the Explorer process which may not running, so let's check first if the process is running.
This commit is contained in:
@@ -36,6 +36,9 @@ $SensitiveData = @(
|
||||
': ->'
|
||||
)
|
||||
|
||||
Write-Host "Show Packer Version"
|
||||
packer --version
|
||||
|
||||
Write-Host "Build $Image VM"
|
||||
packer build -var "capture_name_prefix=$ResourcesNamePrefix" `
|
||||
-var "client_id=$ClientId" `
|
||||
|
||||
@@ -8,7 +8,13 @@ function Disable-InternetExplorerESC {
|
||||
$UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}"
|
||||
Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0 -Force
|
||||
Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0 -Force
|
||||
Stop-Process -Name Explorer -Force -ErrorAction Continue
|
||||
|
||||
$ieProcess = Get-Process -Name Explorer -ErrorAction SilentlyContinue
|
||||
|
||||
if ($ieProcess){
|
||||
Stop-Process -Name Explorer -Force -ErrorAction Continue
|
||||
}
|
||||
|
||||
Write-Host "IE Enhanced Security Configuration (ESC) has been disabled."
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,13 @@ function Disable-InternetExplorerESC {
|
||||
$UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}"
|
||||
Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0 -Force
|
||||
Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0 -Force
|
||||
Stop-Process -Name Explorer -Force -ErrorAction Continue
|
||||
|
||||
$ieProcess = Get-Process -Name Explorer -ErrorAction SilentlyContinue
|
||||
|
||||
if ($ieProcess){
|
||||
Stop-Process -Name Explorer -Force -ErrorAction Continue
|
||||
}
|
||||
|
||||
Write-Host "IE Enhanced Security Configuration (ESC) has been disabled."
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user