mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 07:08:55 +02:00

%~dp0 always contains a trailing backslash. The way %DIR% is used in the following line, the trailing slash should be stripped. Alternatively, `%DIR%\\` may be replaced with `%DIR%`, but I would advice against. It is ok to have `%~dp0trilium-data`, which is a conventional pattern. Once %~dp0 is replaced with %DIR% (which is not really warranted here), stripping the trailing slash right after assignment is preferable.
25 lines
688 B
Batchfile
25 lines
688 B
Batchfile
@echo off
|
|
:: Try to get powershell to launch Trilium since it deals with UTF-8 characters in current path
|
|
:: If there's no powershell available, fallback to unicode enabled command interpreter
|
|
|
|
WHERE powershell.exe > NUL 2>&1
|
|
IF %ERRORLEVEL% NEQ 0 GOTO BATCH ELSE GOTO POWERSHELL
|
|
|
|
:POWERSHELL
|
|
powershell -ExecutionPolicy Bypass -NonInteractive -NoLogo "Set-Item -Path Env:TRILIUM_DATA_DIR -Value './trilium-data'; ./trilium.exe"
|
|
GOTO END
|
|
|
|
:BATCH
|
|
:: Make sure we support UTF-8 characters
|
|
chcp 65001
|
|
|
|
:: Get Current Trilium executable directory and compute data directory
|
|
SET DIR=%~dp0
|
|
SET DIR=%DIR:~0,-1%
|
|
SET TRILIUM_DATA_DIR=%DIR%\trilium-data
|
|
cd "%DIR%"
|
|
start trilium.exe
|
|
GOTO END
|
|
|
|
:END
|