Skip to content

Build your personal knowledge base with Trilium Notes

Add powershell equivalents to existing batch scripts (#2561)

U-Bren780b52050676
diff --git a/bin/build-win-x64.sh b/bin/build-win-x64.sh
index 68ce53001c..c1b8030e49 100755
--- a/bin/build-win-x64.sh
+++ b/bin/build-win-x64.sh
@@ -27,9 +27,7 @@ rm -r $BUILD_DIR/swiftshader
cp bin/tpl/anonymize-database.sql $BUILD_DIR/
-cp bin/tpl/trilium-portable.bat $BUILD_DIR/
-cp bin/tpl/trilium-no-cert-check.bat $BUILD_DIR/
-cp bin/tpl/trilium-safe-mode.bat $BUILD_DIR/
+cp bin/tpl/trilium-{portable,no-cert-check,safe-mode}.{bat,ps1} $BUILD_DIR/
echo "Zipping windows x64 electron distribution..."
VERSION=`jq -r ".version" package.json`
diff --git a/bin/tpl/trilium-no-cert-check.bat b/bin/tpl/trilium-no-cert-check.bat
index e10fa90aca..01a3766850 100644
--- a/bin/tpl/trilium-no-cert-check.bat
+++ b/bin/tpl/trilium-no-cert-check.bat
@@ -1,4 +1,5 @@
SET DIR=%~dp0
set NODE_TLS_REJECT_UNAUTHORIZED=0
cd %DIR%
-start trilium.exe
+WHERE powershell.exe
+IF %ERRORLEVEL% NEQ 0 (start trilium.exe) ELSE (powershell.exe ./trilium-no-cert-check.ps1)
\ No newline at end of file
diff --git a/bin/tpl/trilium-no-cert-check.ps1 b/bin/tpl/trilium-no-cert-check.ps1
new file mode 100644
index 0000000000..43ea010b99
--- /dev/null
+++ b/bin/tpl/trilium-no-cert-check.ps1
@@ -0,0 +1,2 @@
+Set-Item -Path Env:NODE_TLS_REJECT_UNAUTHORIZED -Value 0
+./trilium.exe
\ No newline at end of file
diff --git a/bin/tpl/trilium-portable.bat b/bin/tpl/trilium-portable.bat
index ac65555995..668872d038 100644
--- a/bin/tpl/trilium-portable.bat
+++ b/bin/tpl/trilium-portable.bat
@@ -1,4 +1,5 @@
SET DIR=%~dp0
SET TRILIUM_DATA_DIR=%DIR%\trilium-data
cd %DIR%
-start trilium.exe
\ No newline at end of file
+WHERE powershell.exe
+IF %ERRORLEVEL% NEQ 0 (start trilium.exe) ELSE (powershell.exe ./trilium-portable.ps1)
\ No newline at end of file
diff --git a/bin/tpl/trilium-portable.ps1 b/bin/tpl/trilium-portable.ps1
new file mode 100644
index 0000000000..98bd36cb6d
--- /dev/null
+++ b/bin/tpl/trilium-portable.ps1
@@ -0,0 +1,2 @@
+Set-Item -Path Env:TRILIUM_DATA_DIR -Value './trilium-data'
+./trilium.exe
\ No newline at end of file
diff --git a/bin/tpl/trilium-safe-mode.bat b/bin/tpl/trilium-safe-mode.bat
index a40f03bd82..45fb21c07c 100644
--- a/bin/tpl/trilium-safe-mode.bat
+++ b/bin/tpl/trilium-safe-mode.bat
@@ -1,4 +1,5 @@
SET DIR=%~dp0
SET TRILIUM_SAFE_MODE=1
cd %DIR%
-start trilium.exe
+WHERE powershell.exe
+IF %ERRORLEVEL% NEQ 0 (start trilium.exe) ELSE (powershell.exe ./trilium-safe-mode.ps1)
\ No newline at end of file
diff --git a/bin/tpl/trilium-safe-mode.ps1 b/bin/tpl/trilium-safe-mode.ps1
new file mode 100644
index 0000000000..5fafd5c3e6
--- /dev/null
+++ b/bin/tpl/trilium-safe-mode.ps1
@@ -0,0 +1,2 @@
+Set-Item -Path Env:TRILIUM_SAFE_MODE -Value 1
+./trilium.exe
\ No newline at end of file