@echo off
if not exist "%~dp0CoolInstall.exe" echo Place this batch file in the directory where CoolInstall is located again!  & pause>nul & goto end

reg query "HKLM\SOFTWARE\Classes\.wim" /ve >nul 2>nul
if %errorlevel% equ 0 goto assocwim
reg add "HKLM\SOFTWARE\Classes\.wim" /ve /t REG_SZ /d cifile /f
reg add "HKLM\SOFTWARE\Classes\cifile\shell\open" /ve /t REG_SZ /d "Use the CoolInstall Installation" /f
reg add "HKLM\SOFTWARE\Classes\cifile\shell\open" /v Icon /t REG_SZ /d "%~dp0CoolInstall.exe" /f
reg add "HKLM\SOFTWARE\Classes\cifile\shell\open\command" /ve /t REG_SZ /d "%~dp0CoolInstall.exe /Source:\"%%1\" /f

:Return2
reg query "HKLM\SOFTWARE\Classes\.esd" /ve >nul 2>nul
if %errorlevel% equ 0 goto AssocESD
reg add "HKLM\SOFTWARE\Classes\.esd" /ve /t REG_SZ /d cifile /f
reg add "HKLM\SOFTWARE\Classes\cifile\shell\open" /ve /t REG_SZ /d "Use the CoolInstall Installation" /f
reg add "HKLM\SOFTWARE\Classes\cifile\shell\open" /v Icon /t REG_SZ /d "%~dp0CoolInstall.exe" /f
reg add "HKLM\SOFTWARE\Classes\cifile\shell\open\command" /ve /t REG_SZ /d "%~dp0CoolInstall.exe /Source:\"%%1\" /f

:Return3
reg query "HKLM\SOFTWARE\Classes\.gho" /ve >nul 2>nul
if %errorlevel% equ 0 goto AssocGHO
reg add "HKLM\SOFTWARE\Classes\.gho" /ve /t REG_SZ /d cifile /f
reg add "HKLM\SOFTWARE\Classes\cifile\shell\open" /ve /t REG_SZ /d "Use the CoolInstall Installation" /f
reg add "HKLM\SOFTWARE\Classes\cifile\shell\open" /v Icon /t REG_SZ /d "%~dp0CoolInstall.exe" /f
reg add "HKLM\SOFTWARE\Classes\cifile\shell\open\command" /ve /t REG_SZ /d "%~dp0CoolInstall.exe /Source:\"%%1\" /f

:Return4
reg query "HKLM\SOFTWARE\Classes\.iso" /ve >nul 2>nul
if %errorlevel% equ 0 goto AssocISO
reg add "HKLM\SOFTWARE\Classes\.iso" /ve /t REG_SZ /d cifile /f
reg add "HKLM\SOFTWARE\Classes\cifile\shell\open" /ve /t REG_SZ /d "Use the CoolInstall Installation" /f
reg add "HKLM\SOFTWARE\Classes\cifile\shell\open" /v Icon /t REG_SZ /d "%~dp0CoolInstall.exe" /f
reg add "HKLM\SOFTWARE\Classes\cifile\shell\open\command" /ve /t REG_SZ /d "%~dp0CoolInstall.exe /Source:\"%%1\" /f

:Return5
reg query "HKLM\SOFTWARE\Classes\.swm" /ve >nul 2>nul
if %errorlevel% equ 0 goto AssocSWM
reg add "HKLM\SOFTWARE\Classes\.swm" /ve /t REG_SZ /d cifile /f
reg add "HKLM\SOFTWARE\Classes\cifile\shell\open" /ve /t REG_SZ /d "Use the CoolInstall Installation" /f
reg add "HKLM\SOFTWARE\Classes\cifile\shell\open" /v Icon /t REG_SZ /d "%~dp0CoolInstall.exe" /f
reg add "HKLM\SOFTWARE\Classes\cifile\shell\open\command" /ve /t REG_SZ /d "%~dp0CoolInstall.exe /Source:\"%%1\" /f
goto end

:AssocWIM
for /f "skip=2 tokens=2* delims= " %%i in ('reg query "HKLM\SOFTWARE\Classes\.wim" /ve') do call set WIMType=%%j
reg add "HKLM\SOFTWARE\Classes\%WIMType%\shell\CIS" /ve /t REG_SZ /d "Use the CoolInstall Installation" /f
reg add "HKLM\SOFTWARE\Classes\%WIMType%\shell\CIS" /v Icon /t REG_SZ /d "%~dp0CoolInstall.exe" /f
reg add "HKLM\SOFTWARE\Classes\%WIMType%\shell\CIS\command" /ve /t REG_SZ /d "%~dp0CoolInstall.exe /Source:\"%%1\" /f
goto Return2

:AssocESD
for /f "skip=2 tokens=2* delims= " %%i in ('reg query "HKLM\SOFTWARE\Classes\.esd" /ve') do call set ESDType=%%j
reg add "HKLM\SOFTWARE\Classes\%ESDType%\shell\CIS" /ve /t REG_SZ /d "Use the CoolInstall Installation" /f
reg add "HKLM\SOFTWARE\Classes\%ESDType%\shell\CIS" /v Icon /t REG_SZ /d "%~dp0CoolInstall.exe" /f
reg add "HKLM\SOFTWARE\Classes\%ESDType%\shell\CIS\command" /ve /t REG_SZ /d "%~dp0CoolInstall.exe /Source:\"%%1\" /f
goto Return3

:AssocGHO
for /f "skip=2 tokens=2* delims= " %%i in ('reg query "HKLM\SOFTWARE\Classes\.gho" /ve') do call set GHOType=%%j
reg add "HKLM\SOFTWARE\Classes\%GHOType%\shell\CIS" /ve /t REG_SZ /d "Use the CoolInstall Installation" /f
reg add "HKLM\SOFTWARE\Classes\%GHOType%\shell\CIS" /v Icon /t REG_SZ /d "%~dp0CoolInstall.exe" /f
reg add "HKLM\SOFTWARE\Classes\%GHOType%\shell\CIS\command" /ve /t REG_SZ /d "%~dp0CoolInstall.exe /Source:\"%%1\" /f
goto Return4

:AssocISO
for /f "skip=2 tokens=2* delims= " %%i in ('reg query "HKLM\SOFTWARE\Classes\.iso" /ve') do call set ISOType=%%j
reg add "HKLM\SOFTWARE\Classes\%ISOType%\shell\CIS" /ve /t REG_SZ /d "Use the CoolInstall Installation" /f
reg add "HKLM\SOFTWARE\Classes\%ISOType%\shell\CIS" /v Icon /t REG_SZ /d "%~dp0CoolInstall.exe" /f
reg add "HKLM\SOFTWARE\Classes\%ISOType%\shell\CIS\command" /ve /t REG_SZ /d "%~dp0CoolInstall.exe /Source:\"%%1\" /f
goto Return5

:AssocSWM
for /f "skip=2 tokens=2* delims= " %%i in ('reg query "HKLM\SOFTWARE\Classes\.swm" /ve') do call set SWMType=%%j
reg add "HKLM\SOFTWARE\Classes\%SWMType%\shell\CIS" /ve /t REG_SZ /d "Use the CoolInstall Installation" /f
reg add "HKLM\SOFTWARE\Classes\%SWMType%\shell\CIS" /v Icon /t REG_SZ /d "%~dp0CoolInstall.exe" /f
reg add "HKLM\SOFTWARE\Classes\%SWMType%\shell\CIS\command" /ve /t REG_SZ /d "%~dp0CoolInstall.exe /Source:\"%%1\" /f
goto end

:end