@echo off

color 1f
reg query "HKLM\SOFTWARE\Classes\Windows.IsoFile\shell\ExtractionMount" >nul 2>nul
if %errorlevel% neq 0 goto :create

REM WIM 작업 우클릭 삭제
mode con cols=50 lines=13
echo.&echo.&echo. 우클릭 삭제&echo.&echo.
DEL /A/S/F/Q "C:\Program Files\Portable\OKR\Extraction.cmd"
DEL /A/S/F/Q "C:\Program Files\Portable\OKR\MountISO.exe"
cls
echo.&echo.&echo. 우클릭 삭제&echo.&echo.
Reg delete "HKLM\SOFTWARE\Classes\Windows.IsoFile\shell\ExtractionMount" /f
Reg delete "HKLM\Software\Classes\Windows.IsoFile\shell\burn" /f
Reg add "HKLM\Software\Classes\Windows.IsoFile\shell\burn" /v "MUIVerb" /t REG_EXPAND_SZ /d "@%%SystemRoot%%\System32\isoburn.exe,-351" /f
Reg add "HKLM\Software\Classes\Windows.IsoFile\shell\burn\command" /ve /t REG_EXPAND_SZ /d "%%SystemRoot%%\System32\isoburn.exe \"%%1\"" /f
ping 127.0.0.1 -n 3 >nul
exit

REM WIM 작업 우클릭 생성
:create
mode con cols=50 lines=28
cd /d %~dp0
setlocal enabledelayedexpansion
net session >nul 2>&1 || mshta "javascript:close(new ActiveXObject('shell.application').ShellExecute('%~nx0', '%*', '', 'runas', 1))" && exit
xcopy /hryif "Portable\OKR" "C:\Program Files\Portable\OKR"

cls
echo.&echo.&echo. 우클릭 생성&echo.&echo.
Reg.exe add "HKLM\SOFTWARE\Classes\Windows.IsoFile\shell" /ve /t REG_SZ /d "mount" /f
Reg.exe add "HKLM\SOFTWARE\Classes\Windows.IsoFile\shell\burn" /v "MUIVerb" /t REG_EXPAND_SZ /d "굽기" /f
Reg.exe add "HKLM\SOFTWARE\Classes\Windows.IsoFile\shell\burn" /v "SeparatorBefore" /t REG_SZ /d "" /f
Reg.exe add "HKLM\SOFTWARE\Classes\Windows.IsoFile\shell\burn" /v "icon" /t REG_SZ /d "SHELL32.dll,113" /f
Reg.exe add "HKLM\SOFTWARE\Classes\Windows.IsoFile\shell\burn\command" /ve /t REG_EXPAND_SZ /d "%%SystemRoot%%\System32\isoburn.exe \"%%1\"" /f
Reg.exe add "HKLM\SOFTWARE\Classes\Windows.IsoFile\shell\ExtractionMount" /v "MUIVerb" /t REG_SZ /d "추출" /f
Reg.exe add "HKLM\SOFTWARE\Classes\Windows.IsoFile\shell\ExtractionMount" /v "icon" /t REG_SZ /d "%%SystemRoot%%\System32\SHELL32.dll,151" /f
Reg.exe add "HKLM\SOFTWARE\Classes\Windows.IsoFile\shell\ExtractionMount" /v "SeparatorAfter" /t REG_SZ /d "" /f
Reg.exe add "HKLM\SOFTWARE\Classes\Windows.IsoFile\shell\ExtractionMount" /v "SeparatorBefore" /t REG_SZ /d "" /f
Reg.exe add "HKLM\SOFTWARE\Classes\Windows.IsoFile\shell\ExtractionMount\command" /ve /t REG_SZ /d "C:\Program Files\Portable\OKR\Extraction.cmd \"%%1\"" /f
Reg.exe add "HKLM\SOFTWARE\Classes\Windows.IsoFile\shell\mount" /v "CommandStateSync" /t REG_SZ /d "" /f
Reg.exe add "HKLM\SOFTWARE\Classes\Windows.IsoFile\shell\mount" /v "ExplorerCommandHandler" /t REG_SZ /d "{9ab3b1c9-3225-4bb4-93b6-bfb3c0d93743}" /f
Reg.exe add "HKLM\SOFTWARE\Classes\Windows.IsoFile\shell\mount" /v "MultiSelectModel" /t REG_SZ /d "Document" /f
Reg.exe add "HKLM\SOFTWARE\Classes\Windows.IsoFile\shell\mount\command" /ve /t REG_EXPAND_SZ /d "%%SystemRoot%%\Explorer.exe" /f
Reg.exe add "HKLM\SOFTWARE\Classes\Windows.IsoFile\shell\mount\command" /v "DelegateExecute" /t REG_SZ /d "{9ab3b1c9-3225-4bb4-93b6-bfb3c0d93743}" /f

ping 127.0.0.1 -n 3 >nul
exit
