::@echo off
SET BASEDIR=%~dp0
@IF not "%~1"=="" SET BASEDIR=%~1
@pushd %BASEDIR%
@SET BASEDIR=%CD%\
@popd

@set BASEDIR_=%BASEDIR%
@set SystemRoot_=%SystemRoot%

SET PECMD=PECMD.EXE
@SET PECMDI=
if NOT exist "%BASEDIR%PECMD.EXE" goto :L1
SET PECMD=\"%BASEDIR_%PECMD.EXE\"
SET PECMDI=\"%BASEDIR_%PECMD.EXE\"
:L1
if NOT exist "%BASEDIR%PECMD.NTR" goto :L2
SET PECMD=\"%BASEDIR_%PECMD.NTR\"
IF ""="%PECMDI%" SET PECMDI=\"%BASEDIR_%PECMD.NTR\"
:L2
if NOT exist %SystemRoot%\SYSTEM32\PECMD.EXE goto :L3
SET PECMD=%SystemRoot_%\SYSTEM32\PECMD.EXE
SET PECMDI=%SystemRoot_%\SYSTEM32\PECMD.EXE
:L3
if NOT exist %SystemRoot%\SYSTEM32\PECMD.NTR goto :L4
SET PECMD=%SystemRoot_%\SYSTEM32\PECMD.NTR
IF ""="%PECMDI%" SET PECMDI=%SystemRoot_%\SYSTEM32\PECMD.NTR
:L4
if NOT exist %SystemRoot%\SYSTEM32\PECMD_.EXE goto :L5
SET PECMD=%SystemRoot_%\SYSTEM32\PECMD_.EXE
SET PECMDI=%SystemRoot_%\SYSTEM32\PECMD_.EXE
:L5
if NOT exist %SystemRoot%\SYSTEM32\PECMD_.NTR goto :L6
SET PECMD=%SystemRoot_%\SYSTEM32\PECMD_.NTR
IF ""="%PECMDI%" SET PECMDI=%SystemRoot_%\SYSTEM32\PECMD_.NTR
:L6
@IF ""=="%PECMDI%" SET PECMDI=PECMD.EXE

SET EDIT=notepad
if exist "X:\Program Files\ULTRAEDIT\UEDIT32.EXE" SET EDIT=\"X:\Program Files\ULTRAEDIT\UEDIT32.EXE\" 
if exist X:\Programs\ULTRAEDIT\UEDIT32.EXE        SET EDIT=X:\Programs\ULTRAEDIT\UEDIT32.EXE 
if exist X:\Program\ULTRAEDIT\UEDIT32.EXE         SET EDIT=X:\Program\ULTRAEDIT\UEDIT32.EXE 
if exist X:\Program1\ULTRAEDIT\UEDIT32.EXE        SET EDIT=X:\Program1\ULTRAEDIT\UEDIT32.EXE 
if exist "C:\Program Files\ULTRAEDIT\UEDIT32.EXE" SET EDIT=\"C:\Program Files\ULTRAEDIT\UEDIT32.EXE\" 
if exist "%BASEDIR%UEDIT32.EXE" SET EDIT=\"%BASEDIR_%UEDIT32.EXE\" 

if exist "C:\Program Files\EditPlus 3\editplus.exe" SET EDIT=\"C:\Program Files\EditPlus 3\editplus.exe\" 
if exist "X:\Program Files\EditPlus 3\editplus.exe" SET EDIT=\"X:\Program Files\EditPlus 3\editplus.exe\" 
if exist X:\Programs\EditPlus 3\editplus.exe        SET EDIT=X:\Programs\EditPlus 3\editplus.exe 
if exist X:\Program\EditPlus 3\editplus.exe         SET EDIT=X:\Program\EditPlus 3\editplus.exe 
if exist X:\Program1\EditPlus 3\editplus.exe        SET EDIT=X:\Program1\EditPlus 3\editplus.exe 

if exist "C:\Program Files\EditPlus\editplus.exe" SET EDIT=\"C:\Program Files\EditPlus\editplus.exe\" 
if exist "C:\Program Files\EditPlus 2\editplus.exe" SET EDIT=\"C:\Program Files\EditPlus 2\editplus.exe\" 
if exist "X:\Program Files\EditPlus\editplus.exe" SET EDIT=\"X:\Program Files\EditPlus\editplus.exe\" 
if exist "X:\Program Files\EditPlus 2\editplus.exe" SET EDIT=\"X:\Program Files\EditPlus 2\editplus.exe\" 
if exist X:\Programs\EditPlus 2\editplus.exe        SET EDIT=X:\Programs\EditPlus 2\editplus.exe 
if exist X:\Program\EditPlus 2\editplus.exe         SET EDIT=X:\Program\EditPlus 2\editplus.exe 
if exist X:\Program1\EditPlus 2\editplus.exe        SET EDIT=X:\Program1\EditPlus 2\editplus.exe 


SET EDIT2=-
if exist %SystemRoot%\SYSTEM32\PECMDEDIT.EXE SET EDIT2=%SystemRoot_%\SYSTEM32\PECMDEDIT.EXE
if exist %SystemRoot%\SYSTEM32\PECMDEDIT.NTR SET EDIT2=%SystemRoot_%\SYSTEM32\PECMDEDIT.NTR
if exist %SystemRoot%\SYSTEM32\PECMDEDIT.NTR SET EDIT2=%SystemRoot_%\SYSTEM32\PECMDEDIT.NTR
if exist %SystemRoot%\SYSTEM32\PECMDEDIT.NTR SET EDIT2=%SystemRoot_%\SYSTEM32\PECMDEDIT.NTR
if exist "%BASEDIR%PECMDEDIT.EXE" SET EDIT2=\"%BASEDIR_%PECMDEDIT.EXE\" 
if exist "%BASEDIR%PECMDEDIT.NTR" SET EDIT2=\"%BASEDIR_%PECMDEDIT.NTR\" 

REG ADD HKCR\.ntr   /ve  /d exefile  /f
REG ADD HKCR\.nte   /ve  /d exefile  /f
REG ADD HKCR\.ntx   /ve  /d exefile  /f
REG ADD HKCR\.wcs   /ve  /d wcsfile  /f
REG ADD HKCR\.wce   /ve  /d wcsfile  /f
REG ADD HKCR\.wcx   /ve  /d wcsfile  /f
REG ADD HKCR\.wci   /ve  /d wcsfile  /f
REG ADD HKCR\wcsfile   /ve  /d "WCS 脚本文件"  /f 
REG ADD HKCR\wcsfile\DefaultIcon /ve   /d "%PECMDI%",0  /f
REG ADD HKCR\wcsfile\shell\open\command /ve   /d  "%PECMD% LOAD \"%%L\" %%*"  /f
REG ADD HKCR\wcsfile\shell\Edit\command /ve   /d  "%EDIT% \"%%L\""  /f

REG ADD HKCR\.wcz   /ve  /d wczfile  /f
REG ADD HKCR\wczfile   /ve  /d "WCS 脚本文件"  /f 
REG ADD HKCR\wczfile\DefaultIcon /ve   /d "%PECMDI%",0  /f
REG ADD HKCR\wczfile\shell\open\command /ve   /d  "%PECMD% LOAD \"%%L\" %%*"  /f


REG ADD HKCR\inifile\shell\PECMD /ve   /d  "PECMD 运行"  /f
REG ADD HKCR\inifile\shell\PECMD\command /ve   /d  "%PECMD% LOAD \"%%L\" %%*"  /f

REG ADD HKCR\inifile\shell\PECMDEDIT /ve   /d  "PECMD 编辑"  /f
REG ADD HKCR\inifile\shell\PECMDEDIT\command /ve   /d  "%EDIT% \"%%L\""  /f

@IF  "-"=="%EDIT2%" goto SKIPEDUT2
REG ADD HKCR\inifile\shell\1PECMDEDIT /ve   /d  "PECMDEDIT 编辑"  /f
REG ADD HKCR\inifile\shell\1PECMDEDIT\command /ve   /d  "%EDIT2% \"%%L\""  /f
REG ADD HKCR\wcsfile\shell\1PECMDEDIT /ve   /d  "PECMDEDIT 编辑"  /f
REG ADD HKCR\wcsfile\shell\1PECMDEDIT\command /ve   /d  "%EDIT2% \"%%L\""  /f
:SKIPEDUT2

REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PATHEXT   /d  ".COM;.EXE;.NTR;.NTE;.NTX;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.WCS;.WCE;.WCX;.WCZ"  /f
