From d397990c1a2f9dcbc03953480d19d5bcda1ab330 Mon Sep 17 00:00:00 2001 From: zoicware <118035521+zoicware@users.noreply.github.com> Date: Thu, 30 Oct 2025 16:38:17 -0400 Subject: [PATCH] prevent script hang when backing up ai service fix#35 --- RemoveWindowsAi.ps1 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/RemoveWindowsAi.ps1 b/RemoveWindowsAi.ps1 index bfacff6..f974d6e 100644 --- a/RemoveWindowsAi.ps1 +++ b/RemoveWindowsAi.ps1 @@ -272,7 +272,10 @@ function Disable-Registry-Keys { if (!(Test-Path $backupPath)) { New-Item $backupPath -Force -ItemType Directory | Out-Null } - Reg.exe export 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WSAIFabricSvc' "$backupPath\$backupFile" | Out-Null + #this will hang if the service has already been exported + if (!(Test-Path "$backupPath\$backupFile")) { + Reg.exe export 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WSAIFabricSvc' "$backupPath\$backupFile" | Out-Null + } } Write-Status -msg 'Removing up WSAIFabricSvc...' #delete the service @@ -291,8 +294,8 @@ function Disable-Registry-Keys { else { if ($backup) { #backup .copilot file extension - Reg.exe export 'HKEY_CLASSES_ROOT\.copilot' "$backupPath\HKCR_Copilot.reg" >$null - Reg.exe export 'HKEY_CURRENT_USER\Software\Classes\.copilot' "$backupPath\HKCU_Copilot.reg" >$null + Reg.exe export 'HKEY_CLASSES_ROOT\.copilot' "$backupPath\HKCR_Copilot.reg" *>$null + Reg.exe export 'HKEY_CURRENT_USER\Software\Classes\.copilot' "$backupPath\HKCU_Copilot.reg" *>$null } Write-Status -msg 'Removing .copilot File Extension...' Reg.exe delete 'HKCU\Software\Classes\.copilot' /f *>$null @@ -309,8 +312,8 @@ function Disable-Registry-Keys { if (!(Test-Path $backupPath)) { New-Item $backupPath -Force -ItemType Directory | Out-Null } - Copy-Item $voiceExe -Destination $backupPath -Force | Out-Null - Copy-Item "$startMenu\VoiceAccess.lnk" -Destination $backupPath -Force | Out-Null + Copy-Item $voiceExe -Destination $backupPath -Force -ErrorAction SilentlyContinue | Out-Null + Copy-Item "$startMenu\VoiceAccess.lnk" -Destination $backupPath -Force -ErrorAction SilentlyContinue | Out-Null } if ($revert) {