> Austin.Lai |
> -----------| February 04th, 2025
> -----------| Updated on February 04th, 2025
DISCLAIMER:
This project/repository is provided "as is" and without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.
This project/repository is for Educational purpose ONLY. Do not use it without permission. The usual disclaimer applies, especially the fact that me (Austin) is not liable for any damages caused by direct or indirect use of the information or functionality provided by these programs. The author or any Internet provider bears NO responsibility for content or misuse of these programs or any derivatives thereof. By using these programs you accept the fact that any damage (data loss, system crash, system compromise, etc.) caused by the use of these programs is not Austin responsibility.
This PowerShell script is designed to automate the installation of specific language and font capabilities, as well as other tools (e.g., DirectX), on a Windows system using DISM (Deployment Imaging Service and Management Tool). It provides feedback on the capabilities being installed and whether the process was successful.
Features:
- Installs multiple language OCR and font capabilities, including support for:
- Chinese (Hong Kong & Mainland China)
- Turkish
- Korean
- Japanese
- British English
- Thai, Khmer, Lao, and Japanese fonts
- Installs DirectX tools.
- Displays a list of missing capabilities before and after the installation process.
- Excludes specific capabilities from the list of missing ones:
Language.Basic
Language.TextToSpeech
Language.Speech
Language.Handwriting
Rsat.
- Error handling and status reporting:
- Displays successful or failed installation for each capability.
- Logs any errors encountered during the installation process.
Warning
Use this script at your own risk. The author is not responsible for any damage caused to your system by improper use of the script or installation of unnecessary capabilities.
Important
🚨 Please change the configuration accordingly to suits your environment. 🚨
- Run as Administrator: This script requires administrative privileges. Ensure you run it in a PowerShell window with elevated permissions, otherwise, the installation will fail.
- DISM Tool Requirement: The script uses DISM, which is a part of Windows. Make sure your system has the DISM tool installed and is up-to-date.
- Internet Connection Required: Some capabilities are downloaded from the internet. Ensure that your machine has an active and stable internet connection to download the necessary components.
- Windows Version Compatibility: The capabilities being installed are specific to certain Windows versions. Please ensure your Windows edition supports the listed capabilities.
- System Restart: In some cases, the installation of certain capabilities (especially system-level components) might require a restart. If prompted, restart your system to apply the changes.
- Error Handling: The script includes basic error handling, but unexpected issues may arise. Be sure to monitor the script output and manually troubleshoot if necessary.
- Not All Capabilities May Be Necessary: Before running the script, review the list of capabilities in the script and remove any that are not needed for your system or environment to avoid unnecessary installations.
The install-windows-capability-with-powershell-v1.0.ps1
file can be found here or below:
Click here to expand for the "install-windows-capability-with-powershell-v1.0.ps1" !!!
# Define a list of capabilities to be installed
$capabilities = @(
"Language.OCR~~~zh-HK~0.0.1.0",
"Language.OCR~~~zh-CN~0.0.1.0",
"Language.OCR~~~tr-TR~0.0.1.0",
"Language.OCR~~~ko-KR~0.0.1.0",
"Language.OCR~~~ja-JP~0.0.1.0",
"Language.OCR~~~en-GB~0.0.1.0",
"Language.Fonts.Thai~~~und-THAI~0.0.1.0",
"Language.Fonts.Kore~~~und-KORE~0.0.1.0",
"Language.Fonts.Khmr~~~und-KHMR~0.0.1.0",
"Language.Fonts.Laoo~~~und-LAOO~0.0.1.0",
"Language.Fonts.Jpan~~~und-JPAN~0.0.1.0",
"Tools.Graphics.DirectX~~~~0.0.1.0"
)
# Display a 'Before' message before installing capabilities
Write-Host "`n"
Write-Host "Before" -BackgroundColor White -ForegroundColor Magenta
Write-Host "`n"
# Check for currently missing capabilities (i.e., capabilities that are "Not Present")
# Exclude certain capabilities (Language.Basic, Language.TextToSpeech, Language.Speech, etc.)
DISM /Online /Get-Capabilities |
Select-String "Capability Identity" -Context 0,1 |
Where-Object {
$_.Context.PostContext -match "Not Present" `
-and $_.Line -notmatch "Language.Basic" `
-and $_.Line -notmatch "Language.TextToSpeech" `
-and $_.Line -notmatch "Language.Speech" `
-and $_.Line -notmatch "Language.Handwriting" `
-and $_.Line -notmatch "Rsat."
}
# Loop through the list of capabilities to install each one
foreach ($capability in $capabilities) {
Write-Host "Installing capability: $capability"
try {
# Attempt to add the capability using DISM
DISM /Online /Add-Capability /CapabilityName:$capability
# Check if the installation succeeded
if ($LASTEXITCODE -eq 0) {
Write-Host "Successfully installed $capability" -ForegroundColor Green
} else {
Write-Host "Failed to install $capability" -ForegroundColor Red
}
} catch {
# Catch any errors during installation and display a message
Write-Host "Error occurred while installing $capability" -ForegroundColor Red
}
}
# Display an 'After' message after attempting the installations
Write-Host "`n"
Write-Host "After" -BackgroundColor White -ForegroundColor Magenta
Write-Host "`n"
# Re-check the list of capabilities to see which ones are still "Not Present"
# Apply the same exclusions as before
DISM /Online /Get-Capabilities |
Select-String "Capability Identity" -Context 0,1 |
Where-Object {
$_.Context.PostContext -match "Not Present" `
-and $_.Line -notmatch "Language.Basic" `
-and $_.Line -notmatch "Language.TextToSpeech" `
-and $_.Line -notmatch "Language.Speech" `
-and $_.Line -notmatch "Language.Handwriting" `
-and $_.Line -notmatch "Rsat."
}