From e66ad96f43f2fb288383f53f16e6723b668bb06e Mon Sep 17 00:00:00 2001 From: zoicware <118035521+zoicware@users.noreply.github.com> Date: Thu, 30 Jan 2025 11:37:23 -0800 Subject: [PATCH] Fix #5 --- RemoveAi.ps1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/RemoveAi.ps1 b/RemoveAi.ps1 index caa6272..ea3d4ab 100644 --- a/RemoveAi.ps1 +++ b/RemoveAi.ps1 @@ -251,7 +251,15 @@ $installers = Get-ChildItem -Path $inboxapps -Filter '*Copilot*' foreach ($installer in $installers) { takeown /f $installer.FullName *>$null icacls $installer.FullName /grant administrators:F /t *>$null - Remove-Item -Path $installer.FullName -Force + try { + Remove-Item -Path $installer.FullName -Force -ErrorAction Stop + } + catch { + #takeown didnt work remove file with system priv + $command = "Remove-Item -Path $($installer.FullName) -Force" + Run-Trusted -command $command + } + }