cls
@echo off
if not exist "C:\Program Files\EZWord\" (
    echo 目标目录不存在，正在创建...
    mkdir "C:\Program Files\EZWord\"
    if not exist "C:\Program Files\EZWord\" (
        echo 创建目录失败，请检查权限或路径是否正确！
        exit /b 1
    )
)
Copy /y "%~dp0\EZWord.exe" "C:\Program Files\EZWord\" 
Copy /y "%~dp0\setting.ini" "C:\Program Files\EZWord\" 

set "SOURCE=%~dp0EZWord.dotm"
set "TARGET=%APPDATA%\Microsoft\Word\STARTUP\EZWord.dotm"

:: 检查源文件是否存在
if not exist "%SOURCE%" (
    echo 错误：源文件未找到 -> "%SOURCE%"
    pause
    exit /b 1
)

:: 自动创建目标目录（如果不存在）
if not exist "%APPDATA%\Microsoft\Word\STARTUP\" (
    mkdir "%APPDATA%\Microsoft\Word\STARTUP\"
)

:: 执行复制操作并显示结果
echo 正在更新 Word 模板...
copy /y "%SOURCE%" "%TARGET%"

if errorlevel 1 (
    echo 复制失败！请检查权限或文件占用
) else (
    echo 成功安装EZWord.dotm
)

set "SOURCE=%~dp0Normal.dotm"
set "TARGET=%APPDATA%\Microsoft\Templates\Normal.dotm"

:: 检查源文件是否存在
if not exist "%SOURCE%" (
    echo 错误：源文件未找到 -> "%SOURCE%"
    pause
    exit /b 1
)


:: 执行复制操作并显示结果
echo 正在更新 Word 模板...
copy /y "%SOURCE%" "%TARGET%"

if errorlevel 1 (
    echo 复制失败！请检查权限或文件占用
) else (
    echo 安装成功
)

pause