# This script should be in a file with a .ps1 extension (e.g. indeo.ps1).
# To run this script right click on it and choose "Run with PowerShell" 
# or if your system does not allow running unsigned ps1 scripts you can use the command: 
# "powershell.exe -noprofile -executionpolicy bypass -file .\indeo.ps1"
# Do not edit this file unless you know what you are doing.
###########################################################

Write-Host "Indeo codec enabler/disabler for Win8-Win11"
Write-Host "-------------------------------------------`n"
Write-Host "This PowerShell script will generate .reg files to enable or 
disable the built-in Indeo codecs for Windows 8, 10 and 11:
- Intel Indeo(R) Video R3.2
- Intel Indeo(R) Video 4.5
- Indeo(R)-video 5.10
- Indeo(R) audio software
`n"
Write-Host "Disclaimer: Microsoft has disabled the built-in Indeo codecs due to 
vulnerabilities.(Microsoft Security Advisory 954157) If you 
enable them you are doing so on your own risk.
`n" -BackgroundColor Red -ForegroundColor White

# y/n Prompt:
$confirmation = Read-Host "Continue? [y/n]"
while ($confirmation -ne "y")
{
    if ($confirmation -eq 'n') {exit}
    $confirmation = Read-Host "Continue? [y/n]"
}

# Get OS build number:
#[int]$ver = (Get-CimInstance Win32_OperatingSystem).BuildNumber
[int]$ver = [System.Environment]::OSVersion.Version.Build

# Compare to minimum supported build number:
if($ver -lt 9200)
{
    Write-Host "build number: $ver"
    Write-Host "Needs Windows 8 (build number 9200) or newer to run."
    $confirmation = Read-Host "Press Enter to exit"
    exit
}

# Determine OS bits 64 or 32:
if([Environment]::Is64BitOperatingSystem -like "True")
{
    # Verify that indeo codec files exist:
    if (-Not (Test-Path -Path "$Env:windir\SysWOW64\ir50_32original.dll"))
    {
        Write-Host "ERROR! Proper Indeo codec file not found in system."
        $confirmation = Read-Host "Press Enter to exit"
        exit
    }
    # Set windir variable and trim it to just the drive letter:
    $_windir=$Env:windir -replace ":.*"
    # Set trademark symbol variable:
    $_tradmk=[char]0x00AE
    # Spitting out the reg files:
    Out-File -FilePath .\indeo_codecs_enable.reg

    'Windows Registry Editor Version 5.00' | Out-File -FilePath .\indeo_codecs_enable.reg

    '' | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\drivers.desc]' | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '"{0}:\\Windows\\system32\\ir32_32original.dll"="Intel Indeo(R) Video R3.2"' -f $_windir | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Drivers32]' | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '"vidc.iv32"="{0}:\\Windows\\system32\\ir32_32original.dll"' -f $_windir | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\drivers.desc]' | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '"{0}:\\Windows\\system32\\ir41_32original.dll"="Intel Indeo{1} Video 4.5"' -f $_windir, $_tradmk | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Drivers32]' | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '"vidc.iv41"="{0}:\\Windows\\system32\\ir41_32original.dll"' -f $_windir | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\drivers.desc]' | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '"{0}:\\Windows\\system32\\ir50_32original.dll"="Indeo{1}-video 5.10"' -f $_windir, $_tradmk | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Drivers32]' | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '"vidc.iv50"="{0}:\\Windows\\system32\\ir50_32original.dll"' -f $_windir | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\drivers.desc]' | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '"{0}:\\Windows\\system32\\iac25_32.ax"="Indeo{1} audio software"' -f $_windir, $_tradmk | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Drivers32]' | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '"msacm.iac2"="{0}:\\Windows\\system32\\iac25_32.ax"' -f $_windir | Out-File -FilePath .\indeo_codecs_enable.reg -Append

    Out-File -FilePath .\indeo_codecs_disable.reg

    'Windows Registry Editor Version 5.00' | Out-File -FilePath .\indeo_codecs_disable.reg

    '' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\drivers.desc]' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '"{0}:\\Windows\\system32\\ir32_32original.dll"=-' -f $_windir | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Drivers32]' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '"vidc.iv32"=-' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\drivers.desc]' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '"{0}:\\Windows\\system32\\ir41_32original.dll"=-' -f $_windir | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Drivers32]' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '"vidc.iv41"=-' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\drivers.desc]' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '"{0}:\\Windows\\system32\\ir50_32original.dll"=-' -f $_windir | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Drivers32]' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '"vidc.iv50"=-' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\drivers.desc]' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '"{0}:\\Windows\\system32\\iac25_32.ax"=-' -f $_windir | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Drivers32]' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '"msacm.iac2"=-' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
}

else # 32-bit OS (x86)
{
    # Verify that indeo codec files exist:
    if (-Not (Test-Path -Path "$Env:windir\System32\ir50_32original.dll"))
    {
        Write-Host "ERROR! Proper Indeo codec file not found in system."
        $confirmation = Read-Host "Press Enter to exit"
        exit
    }
    # Set windir variable and trim it to just the drive letter:
    $_windir=$Env:windir -replace ":.*"
    # Set trademark symbol variable:
    $_tradmk=[char]0x00AE
    # Spitting out the reg files:
    Out-File -FilePath .\indeo_codecs_enable.reg

    'Windows Registry Editor Version 5.00' | Out-File -FilePath .\indeo_codecs_enable.reg

    '' | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\drivers.desc]' | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '"{0}:\\Windows\\system32\\ir32_32original.dll"="Intel Indeo(R) Video R3.2"' -f $_windir | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32]' | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '"vidc.iv32"="{0}:\\Windows\\system32\\ir32_32original.dll"' -f $_windir | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\drivers.desc]' | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '"{0}:\\Windows\\system32\\ir41_32original.dll"="Intel Indeo{1} Video 4.5"' -f $_windir, $_tradmk | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32]' | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '"vidc.iv41"="{0}:\\Windows\\system32\\ir41_32original.dll"' -f $_windir | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\drivers.desc]' | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '"{0}:\\Windows\\system32\\ir50_32original.dll"="Indeo{1}-video 5.10"' -f $_windir, $_tradmk | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32]' | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '"vidc.iv50"="{0}:\\Windows\\system32\\ir50_32original.dll"' -f $_windir | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\drivers.desc]' | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '"{0}:\\Windows\\system32\\iac25_32.ax"="Indeo{1} audio software"' -f $_windir, $_tradmk | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32]' | Out-File -FilePath .\indeo_codecs_enable.reg -Append
    '"msacm.iac2"="{0}:\\Windows\\system32\\iac25_32.ax"' -f $_windir | Out-File -FilePath .\indeo_codecs_enable.reg -Append

    Out-File -FilePath .\indeo_codecs_disable.reg

    'Windows Registry Editor Version 5.00' | Out-File -FilePath .\indeo_codecs_disable.reg

    '' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\drivers.desc]' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '"{0}:\\Windows\\system32\\ir32_32original.dll"=-' -f $_windir | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32]' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '"vidc.iv32"=-' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\drivers.desc]' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '"{0}:\\Windows\\system32\\ir41_32original.dll"=-' -f $_windir | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32]' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '"vidc.iv41"=-' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\drivers.desc]' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '"{0}:\\Windows\\system32\\ir50_32original.dll"=-' -f $_windir | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32]' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '"vidc.iv50"=-' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\drivers.desc]' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '"{0}:\\Windows\\system32\\iac25_32.ax"=-' -f $_windir | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32]' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
    '"msacm.iac2"=-' | Out-File -FilePath .\indeo_codecs_disable.reg -Append
}

Write-Host "`n.reg files generated run them to enable or disable the Indeo codecs." -BackgroundColor Green -ForegroundColor Black
[console]::beep(500,300) # Plays a beep sound.
$confirmation = Read-Host "Press Enter to exit"
exit
