# Extract CHM file using PowerShell and HTML Help ActiveX param( [string]$ChmFile = "C:\GEVISOFT\Documentation\GeViSoft .NET SDK API Documentation.chm", [string]$OutputDir = "C:\DEV\COPILOT\SOURCES\GeViSoft_API_Documentation_extracted" ) # Create output directory New-Item -ItemType Directory -Force -Path $OutputDir | Out-Null # Try using expand.exe (Windows built-in) Write-Host "Attempting to extract using expand.exe..." $tempDir = Join-Path $env:TEMP "chm_extract" New-Item -ItemType Directory -Force -Path $tempDir | Out-Null # CHM files are compiled HTML Help files - we can try extracting with expand $result = & expand.exe "$ChmFile" -F:* "$tempDir" 2>&1 if (Test-Path "$tempDir\*") { Write-Host "Extraction successful with expand.exe" Copy-Item -Path "$tempDir\*" -Destination $OutputDir -Recurse -Force Write-Host "Files copied to $OutputDir" } else { Write-Host "expand.exe failed, trying alternative method..." # Try using 7-Zip if available (check common locations) $7zipPaths = @( "C:\Program Files\7-Zip\7z.exe", "C:\Program Files (x86)\7-Zip\7z.exe", "$env:ProgramFiles\7-Zip\7z.exe" ) $7zip = $7zipPaths | Where-Object { Test-Path $_ } | Select-Object -First 1 if ($7zip) { Write-Host "Found 7-Zip at: $7zip" & $7zip x "$ChmFile" "-o$OutputDir" -y Write-Host "Extracted with 7-Zip to $OutputDir" } else { Write-Host "7-Zip not found. Please install 7-Zip or use another method." Write-Host "You can download 7-Zip from: https://www.7-zip.org/" exit 1 } } # Count extracted files $fileCount = (Get-ChildItem -Path $OutputDir -Recurse -File).Count Write-Host "Total files extracted: $fileCount"