@echo off
setlocal enabledelayedexpansion

:: 目标目录（当前用户的 Local\LTspice）
set "DEST=%LOCALAPPDATA%\LTspice"

:: 1. 创建目标目录（如果不存在）
if not exist "%DEST%" (
    mkdir "%DEST%"
    echo 已创建目录: %DEST%
)

:: 2. 解压 examples.zip
if exist "examples.zip" (
    echo 正在解压 examples.zip ...
    powershell -command "Expand-Archive -Path 'examples.zip' -DestinationPath '%DEST%' -Force"
    echo 解压完成。
) else (
    echo 警告: 未找到 examples.zip，请确保该文件与批处理在同一目录。
)

:: 3. 解压 lib.zip
if exist "lib.zip" (
    echo 正在解压 lib.zip ...
    powershell -command "Expand-Archive -Path 'lib.zip' -DestinationPath '%DEST%' -Force"
    echo 解压完成。
) else (
    echo 警告: 未找到 lib.zip，请确保该文件与批处理在同一目录。
)

:: 4. 创建桌面快捷方式（假设 LTspice.exe 在目标目录下）
set "DESKTOP=%USERPROFILE%\Desktop"
set "TARGET=%DEST%\LTspice.exe"
if exist "%TARGET%" (
    echo 正在创建桌面快捷方式 ...
    powershell -command "$WshShell = New-Object -comObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut('%DESKTOP%\LTspice.lnk'); $Shortcut.TargetPath = '%TARGET%'; $Shortcut.Save()"
    echo 快捷方式已创建: %DESKTOP%\LTspice.lnk
) else (
    echo 错误: 未找到 %TARGET%，请确认 LTspice.exe 已放置在 %DEST% 目录下。
    echo 快捷方式未被创建。
)

echo 操作完成。
pause