Files
Lannamokia_vhdmount/setup_task.bat
T
Lannamokia e323921ce2 feat: 重构VHD挂载逻辑并添加关机事件处理
- 将开机启动注册改为Windows计划任务方式
- 重命名UnmountDrive为UnmountVHD并改进实现
- 添加系统关机事件监听确保安全卸载VHD
- 更新README文档说明新功能
- 删除不再使用的StartupManager类
2025-08-16 00:43:50 +08:00

43 lines
1.3 KiB
Batchfile

@echo off
REM VHD Mounter - Setup Windows Scheduled Task
REM This script creates a scheduled task to run VHDMounter.exe at user logon with highest privileges
echo Setting up VHD Mounter scheduled task...
REM Get current directory
set "CURRENT_DIR=%~dp0"
set "EXE_PATH=%CURRENT_DIR%VHDMounter.exe"
REM Check if VHDMounter.exe exists
if not exist "%EXE_PATH%" (
echo ERROR: VHDMounter.exe not found in current directory
echo Please make sure VHDMounter.exe is in the same folder as this script
pause
exit /b 1
)
echo Found VHDMounter.exe at: %EXE_PATH%
REM Delete existing task if it exists
echo Removing existing task if present...
schtasks /delete /tn "VHDMounter" /f >nul 2>&1
REM Create new scheduled task
echo Creating new scheduled task...
schtasks /create /tn "VHDMounter" /tr "\"%EXE_PATH%\"" /sc onlogon /rl highest /f
if %errorlevel% equ 0 (
echo SUCCESS: VHD Mounter scheduled task created successfully
echo The task will run VHDMounter.exe at user logon with highest privileges
echo Task Name: VHDMounter
echo Trigger: At logon
echo Run Level: Highest
echo Executable: %EXE_PATH%
) else (
echo ERROR: Failed to create scheduled task
echo Please make sure you are running this script as Administrator
)
echo.
echo Press any key to exit...
pause >nul