Skip to content

Commit

Permalink
Provisioning: Help script for removing items
Browse files Browse the repository at this point in the history
Sometimes items are locked (access denied) so we need to have function
which waits and retry until removing is possible.

Task-number: QTQAINFRA-2806
Change-Id: I09055c45c0e439ed1a20eb575ee79b7ca22c5745
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
  • Loading branch information
hehalmet authored and Tony Sarajärvi committed Mar 10, 2019
1 parent afa1b05 commit 76c8086
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
19 changes: 19 additions & 0 deletions coin/provisioning/common/windows/helpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,22 @@ function IsProxyEnabled {
function Get-Proxy {
return (Get-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings').proxyServer
}

function Remove {

Param (
[string]$Path = $(BadParam("a path"))
)
Write-Host "Removing $Path"
$i = 0
While ( Test-Path($Path) ){
Try{
remove-item -Force -Recurse -Path $Path -ErrorAction Stop
}catch{
$i +=1
if ($i -eq 5) {exit 1}
Write-Verbose "$Path locked, trying again in 5"
Start-Sleep -seconds 5
}
}
}
3 changes: 1 addition & 2 deletions coin/provisioning/common/windows/vc_redist.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,4 @@ Download $externalUrl $internalUrl $package
Verify-Checksum $package $sha1
Write-Host "Installing $package..."
Run-Executable $package "/q"
Write-Host "Remove $package..."
Remove-Item -Force -Path $package
Remove $package

0 comments on commit 76c8086

Please sign in to comment.