diff options
author | Heikki Halmet <heikki.halmet@qt.io> | 2019-02-15 13:28:47 +0200 |
---|---|---|
committer | Tony Sarajärvi <tony.sarajarvi@qt.io> | 2019-03-10 14:32:03 +0000 |
commit | 76c80866af78274eeb973ab38ad7b44f216b1a1e (patch) | |
tree | ea1c1056662a0180f1a91ddb0bd17c3a35f63c47 /coin/provisioning/common/windows/helpers.ps1 | |
parent | afa1b053fed7c1be94f4f639d608479e9e39974d (diff) |
Provisioning: Help script for removing items
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>
Diffstat (limited to 'coin/provisioning/common/windows/helpers.ps1')
-rw-r--r-- | coin/provisioning/common/windows/helpers.ps1 | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/coin/provisioning/common/windows/helpers.ps1 b/coin/provisioning/common/windows/helpers.ps1 index 76ad4867..f5318bcb 100644 --- a/coin/provisioning/common/windows/helpers.ps1 +++ b/coin/provisioning/common/windows/helpers.ps1 @@ -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 + } + } +} |