# One-click user install (no admin required). $ErrorActionPreference = 'Stop' $Root = Split-Path -Parent $MyInvocation.MyCommand.Path $Dest = Join-Path $env:LOCALAPPDATA 'rclone-dropbox-bisync' New-Item -ItemType Directory -Force -Path (Join-Path $Dest 'bin') | Out-Null Copy-Item -Force (Join-Path $Root 'rclone.exe') (Join-Path $Dest 'bin\rclone.exe') Copy-Item -Force (Join-Path $Root 'rclone-bisyncd.exe') (Join-Path $Dest 'bin\rclone-bisyncd.exe') Copy-Item -Force (Join-Path $Root 'tray.ps1') (Join-Path $Dest 'tray.ps1') $cfg = Join-Path $Dest 'config.json' if (-not (Test-Path $cfg)) { Copy-Item (Join-Path $Root 'config.example.json') $cfg $j = Get-Content $cfg -Raw | ConvertFrom-Json $j.rclone = Join-Path $Dest 'bin\rclone.exe' $j.enabled = $false $j.session_name = 'datastorage-dropbox' $j | ConvertTo-Json | Set-Content -Encoding UTF8 $cfg } $bin = Join-Path $Dest 'bin' $userPath = [Environment]::GetEnvironmentVariable('Path', 'User') if ($userPath -notlike "*$bin*") { [Environment]::SetEnvironmentVariable('Path', "$bin;$userPath", 'User') } $run = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Run' New-ItemProperty -Path $run -Name 'rclone-dropbox-bisync' -PropertyType String -Force ` -Value "powershell.exe -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -File `"$Dest\tray.ps1`"" | Out-Null $daemon = Join-Path $Dest 'bin\rclone-bisyncd.exe' New-ItemProperty -Path $run -Name 'rclone-dropbox-bisync-daemon' -PropertyType String -Force ` -Value "`"$daemon`"" | Out-Null schtasks /Delete /F /TN 'rclone-dropbox-bisync' 2>$null schtasks /Create /F /TN 'rclone-dropbox-bisync' /SC ONLOGON /RL LIMITED /TR "`"$daemon`"" | Out-Null Start-Process powershell.exe -WindowStyle Hidden -ArgumentList @( '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', (Join-Path $Dest 'tray.ps1') ) Start-Process $daemon -WindowStyle Hidden Add-Type -AssemblyName PresentationFramework [System.Windows.MessageBox]::Show("Installed to $Dest`r`nCopy RCLONE_TEST to dropbox:, set enabled=true, then rclone-bisyncd --accept-resync.", 'rclone-dropbox-bisync')