@echo off
REM 关联ESD\WIM\GHO\ISO的右键菜单“使用CoolInstall安装”的批处理示例，由无忧@Bluebells编写。
if not exist "%~dp0CoolInstall.exe" echo 请将此批处理文件放置在 CoolInstall 所在目录再执行! & pause>nul & goto end

reg query "HKLM\SOFTWARE\Classes\.wim" /ve >nul 2>nul
if %errorlevel% equ 0 goto assocwim
echo Y|reg add "HKLM\SOFTWARE\Classes\.wim" /ve /t REG_SZ /d cifile /f
echo Y|reg add "HKLM\SOFTWARE\Classes\cifile\shell\open" /ve /t REG_SZ /d "用 &CoolInstall 安装" /f
echo Y|reg add "HKLM\SOFTWARE\Classes\cifile\shell\open" /v Icon /t REG_SZ /d "%~dp0CoolInstall.exe" /f
echo Y|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
echo Y|reg add "HKLM\SOFTWARE\Classes\.esd" /ve /t REG_SZ /d cifile /f
echo Y|reg add "HKLM\SOFTWARE\Classes\cifile\shell\open" /ve /t REG_SZ /d "用 &CoolInstall 安装" /f
echo Y|reg add "HKLM\SOFTWARE\Classes\cifile\shell\open" /v Icon /t REG_SZ /d "%~dp0CoolInstall.exe" /f
echo Y|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
echo Y|reg add "HKLM\SOFTWARE\Classes\.gho" /ve /t REG_SZ /d cifile /f
echo Y|reg add "HKLM\SOFTWARE\Classes\cifile\shell\open" /ve /t REG_SZ /d "用 &CoolInstall 安装" /f
echo Y|reg add "HKLM\SOFTWARE\Classes\cifile\shell\open" /v Icon /t REG_SZ /d "%~dp0CoolInstall.exe" /f
echo Y|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
echo Y|reg add "HKLM\SOFTWARE\Classes\.iso" /ve /t REG_SZ /d cifile /f
echo Y|reg add "HKLM\SOFTWARE\Classes\cifile\shell\open" /ve /t REG_SZ /d "用 &CoolInstall 安装" /f
echo Y|reg add "HKLM\SOFTWARE\Classes\cifile\shell\open" /v Icon /t REG_SZ /d "%~dp0CoolInstall.exe" /f
echo Y|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
echo Y|reg add "HKLM\SOFTWARE\Classes\.swm" /ve /t REG_SZ /d cifile /f
echo Y|reg add "HKLM\SOFTWARE\Classes\cifile\shell\open" /ve /t REG_SZ /d "用 &CoolInstall 安装" /f
echo Y|reg add "HKLM\SOFTWARE\Classes\cifile\shell\open" /v Icon /t REG_SZ /d "%~dp0CoolInstall.exe" /f
echo Y|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
echo Y|reg add "HKLM\SOFTWARE\Classes\%WIMType%\shell\CIS" /ve /t REG_SZ /d "用 &CoolInstall 安装" /f
echo Y|reg add "HKLM\SOFTWARE\Classes\%WIMType%\shell\CIS" /v Icon /t REG_SZ /d "%~dp0CoolInstall.exe" /f
echo Y|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
echo Y|reg add "HKLM\SOFTWARE\Classes\%ESDType%\shell\CIS" /ve /t REG_SZ /d "用 &CoolInstall 安装" /f
echo Y|reg add "HKLM\SOFTWARE\Classes\%ESDType%\shell\CIS" /v Icon /t REG_SZ /d "%~dp0CoolInstall.exe" /f
echo Y|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
echo Y|reg add "HKLM\SOFTWARE\Classes\%GHOType%\shell\CIS" /ve /t REG_SZ /d "用 &CoolInstall 安装" /f
echo Y|reg add "HKLM\SOFTWARE\Classes\%GHOType%\shell\CIS" /v Icon /t REG_SZ /d "%~dp0CoolInstall.exe" /f
echo Y|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
echo Y|reg add "HKLM\SOFTWARE\Classes\%ISOType%\shell\CIS" /ve /t REG_SZ /d "用 &CoolInstall 安装" /f
echo Y|reg add "HKLM\SOFTWARE\Classes\%ISOType%\shell\CIS" /v Icon /t REG_SZ /d "%~dp0CoolInstall.exe" /f
echo Y|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
echo Y|reg add "HKLM\SOFTWARE\Classes\%SWMType%\shell\CIS" /ve /t REG_SZ /d "用 &CoolInstall 安装" /f
echo Y|reg add "HKLM\SOFTWARE\Classes\%SWMType%\shell\CIS" /v Icon /t REG_SZ /d "%~dp0CoolInstall.exe" /f
echo Y|reg add "HKLM\SOFTWARE\Classes\%SWMType%\shell\CIS\command" /ve /t REG_SZ /d "%~dp0CoolInstall.exe /Source:\"%%1\" /f
goto end

:end
pause