Add Windows autostart setup
This commit is contained in:
@@ -7,6 +7,7 @@ wheels/
|
|||||||
*.egg-info
|
*.egg-info
|
||||||
tests/resource/
|
tests/resource/
|
||||||
docutranslate/output/
|
docutranslate/output/
|
||||||
|
logs/
|
||||||
# Shared glossary runtime data
|
# Shared glossary runtime data
|
||||||
data/
|
data/
|
||||||
# Virtual environments
|
# Virtual environments
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
@echo off
|
||||||
|
setlocal
|
||||||
|
|
||||||
|
cd /d "%~dp0"
|
||||||
|
|
||||||
|
set "TASK_NAME=DocuTranslate"
|
||||||
|
set "PROJECT_DIR=%~dp0"
|
||||||
|
set "RUN_BAT=%PROJECT_DIR%run.bat"
|
||||||
|
set "LOG_DIR=%PROJECT_DIR%logs"
|
||||||
|
set "LOG_FILE=%LOG_DIR%\autostart.log"
|
||||||
|
|
||||||
|
if not exist "%RUN_BAT%" (
|
||||||
|
echo [ERROR] Cannot find "%RUN_BAT%".
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
if not exist "%LOG_DIR%" mkdir "%LOG_DIR%"
|
||||||
|
|
||||||
|
REM Create a startup task. Run this file as Administrator.
|
||||||
|
REM The task runs as SYSTEM, so it can start after reboot before desktop login.
|
||||||
|
schtasks /Create ^
|
||||||
|
/TN "%TASK_NAME%" ^
|
||||||
|
/SC ONSTART ^
|
||||||
|
/RU SYSTEM ^
|
||||||
|
/RL HIGHEST ^
|
||||||
|
/TR "cmd.exe /c cd /d ""%PROJECT_DIR%"" && ""%RUN_BAT%"" >> ""%LOG_FILE%"" 2>&1" ^
|
||||||
|
/F
|
||||||
|
|
||||||
|
if not "%ERRORLEVEL%"=="0" (
|
||||||
|
echo.
|
||||||
|
echo [ERROR] Failed to create scheduled task. Please run this file as Administrator.
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo [OK] Scheduled task "%TASK_NAME%" has been created.
|
||||||
|
echo [OK] It will run "%RUN_BAT%" at system startup.
|
||||||
|
echo [OK] Log file: "%LOG_FILE%"
|
||||||
|
echo.
|
||||||
|
echo You can start it now with:
|
||||||
|
echo schtasks /Run /TN "%TASK_NAME%"
|
||||||
|
echo.
|
||||||
|
pause
|
||||||
Reference in New Issue
Block a user