e-taxソフトでインストール失敗したときに消すヤツ
管理者権限でPowerShellを起動して実行
powershell -NoProfile -ExecutionPolicy Bypass -File .\etaxrm.ps1
| [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] | |
| param() | |
| $ErrorActionPreference = 'Stop' | |
| function Test-IsAdministrator { | |
| $currentIdentity = [Security.Principal.WindowsIdentity]::GetCurrent() | |
| $principal = New-Object Security.Principal.WindowsPrincipal($currentIdentity) | |
| return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) | |
| } | |
| if (-not (Test-IsAdministrator)) { | |
| throw "Run this script in an elevated PowerShell session." | |
| } | |
| if (-not [Environment]::Is64BitOperatingSystem) { | |
| throw "This script requires a 64-bit Windows OS." | |
| } | |
| $targets = @( | |
| @{ | |
| Type = 'Registry' | |
| Path = 'HKLM:\SOFTWARE\Wow6432Node\nta' | |
| Label = 'HKLM\SOFTWARE\Wow6432Node\nta' | |
| }, | |
| @{ | |
| Type = 'Directory' | |
| Path = 'C:\Program Files (x86)\etax' | |
| Label = 'C:\Program Files (x86)\etax' | |
| }, | |
| @{ | |
| Type = 'Directory' | |
| Path = 'C:\Program Files (x86)\InstallShield Installation Information\{1ECF5EFF-BCDE-484C-A0A8-E4A86FEA3B59}' | |
| Label = 'C:\Program Files (x86)\InstallShield Installation Information\{1ECF5EFF-BCDE-484C-A0A8-E4A86FEA3B59}' | |
| } | |
| ) | |
| Write-Host 'Checking targets...' -ForegroundColor Cyan | |
| foreach ($target in $targets) { | |
| $exists = Test-Path -LiteralPath $target.Path | |
| if ($exists) { | |
| Write-Host "[FOUND] $($target.Label)" -ForegroundColor Yellow | |
| } | |
| else { | |
| Write-Host "[SKIP ] $($target.Label) (not found)" -ForegroundColor DarkGray | |
| } | |
| } | |
| Write-Host '' | |
| Write-Host 'Starting removal...' -ForegroundColor Cyan | |
| foreach ($target in $targets) { | |
| if (-not (Test-Path -LiteralPath $target.Path)) { | |
| continue | |
| } | |
| if ($PSCmdlet.ShouldProcess($target.Label, 'Remove')) { | |
| Remove-Item -LiteralPath $target.Path -Recurse -Force | |
| Write-Host "[DONE ] $($target.Label)" -ForegroundColor Green | |
| } | |
| } | |
| Write-Host '' | |
| Write-Host 'Completed.' -ForegroundColor Green |