Skip to content

Commit

Permalink
silently ignore non-existent files (#760)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfriesen authored Dec 10, 2024
1 parent 6d1aa1a commit 7802269
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/xdpruntime/xdp-setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ function Cleanup-Service($Name) {
}
}

function Cleanup-File($Path) {
Write-Verbose "Cleaning up $Path"
if (Test-Path $Path) {
Write-Verbose "Remove-Item $Path -Force"
Remove-Item $Path -Force
} else {
Write-Verbose "$Path did not exist"
}
}

# Helper to uninstall a driver from its inf file.
function Uninstall-Driver($Inf) {
# Expected pnputil enum output is:
Expand Down Expand Up @@ -155,8 +165,8 @@ function Uninstall-XdpComponent($ComponentId) {

Cleanup-Service xdp

Remove-Item $env:WINDIR\system32\xdpapi.dll -Force
Remove-Item $env:WINDIR\system32\drivers\xdp.sys -Force
Cleanup-File $env:WINDIR\system32\xdpapi.dll
Cleanup-File $env:WINDIR\system32\drivers\xdp.sys

Write-Verbose "xdp.sys uninstall complete!"
}
Expand Down

0 comments on commit 7802269

Please sign in to comment.