From 3fbef2b19bea482dc5b0d873e1c8587a2a7c3e6c Mon Sep 17 00:00:00 2001
From: "Michael H.G. Schmidt" <michael@schmidt2.de>
Date: Sun, 18 Dec 2022 21:08:07 +0100
Subject: [PATCH] .

---
 optional/install-seafile.cmd |  4 ----
 tools/logon.cmd              | 26 +++++++++++++++++---------
 2 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/optional/install-seafile.cmd b/optional/install-seafile.cmd
index 5ec3560..5011e7c 100644
--- a/optional/install-seafile.cmd
+++ b/optional/install-seafile.cmd
@@ -21,10 +21,6 @@ msiexec /i %MSI% /qn
 @echo off
 cd %OPT%
 
-echo remapping Desktop folder to standard location ...
-reg add "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" ^
-  /v Desktop /t REG_EXPAND_SZ /d "%USERPROFILE%\Desktop" /f 1>nul
-
 echo restarting explorer ...
 taskkill /f /im explorer.exe 1>nul 2>nul
 start explorer.exe
diff --git a/tools/logon.cmd b/tools/logon.cmd
index 1d05305..4d220da 100644
--- a/tools/logon.cmd
+++ b/tools/logon.cmd
@@ -98,10 +98,23 @@ echo remapping Desktop folder to standard location ...
 reg add "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" ^
   /v Desktop /t REG_EXPAND_SZ /d "%%USERPROFILE%%\Desktop" /f 1>nul
 
+rem SEAFILE
+rem fix for broken SEAFILE folder access rights ...
+if EXIST %USERPROFILE%\Seafile (
+  echo removing SEAFILE system attributes ...
+  attrib -S %USERPROFILE%\Seafile /S /D 
+)
 
-rem ================================================
-rem USER TWEAKS AND CONFIG FILES (this runs always)
-rem ================================================
+rem adding autostart for SEAFILE ...
+if EXIST "%ProgramFiles%\Seafile\bin\seafile-applet.exe" (
+  reg add "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" ^
+    /v Seafile /t REG_SZ /d "%ProgramFiles%\Seafile\bin\seafile-applet.exe" /f 1>nul
+)
+
+
+rem ==================================================
+rem USER TWEAKS AND CONFIG FILES (this runs only once)
+rem ==================================================
 
 rem User tweaks already done ?
 if EXIST %USERCONFIG_DONE% GOTO USERTWEAKS_DONE
@@ -132,12 +145,7 @@ copy /Y %TOOLS%\optional\config\WINCMD.ini %APPDATA%\GHISLER
 echo copying TOTALCOMMANDER ftp config file ...
 copy /Y %TOOLS%\optional\config\wcx_ftp.ini %APPDATA%\GHISLER
 
-rem fix for broken SEAFILE folder access rights ...
-if EXIST %USERPROFILE%\Seafile (
-  echo removing SEAFILE system attributes ...
-  attrib -S %USERPROFILE%\Seafile /S /D 
-)
-
+rem THISPC
 echo Adding "This PC" icon for current user on desktop Windows 10 ...
 reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" ^
  /v "{20D04FE0-3AEA-1069-A2D8-08002B30309D}" /t REG_DWORD /d 0 /f 1>nul