|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- @echo off
- setlocal enabledelayedexpansion
- set cmdstr=rsync
- set zipfile=cwrsync.zip
- set downurl=https://itefix.net/dl/free-software/cwrsync_6.3.0_x64_free.zip
- set currpath=%~dp0
- set "rsynchome=%ProgramFiles%\%zipfile:~0,-4%"
- set passfile=%temp%\.password
- set syncdir=dist/
- :: Ҫͬ
- set accountwithost=kszny@47.96.93.140::line
- set "password=kszny@123"
- set "runcommand=%cmdstr% --port=873 -rlptvz --progress --password-file=%passfile% --exclude=google.exe --exclude=Lodap.zip %syncdir% %accountwithost%"
-
- where %cmdstr% >nul 2>nul
- ::д˵ڸ
- if %errorlevel% neq 0 (
- ::δذװδѹװĿ¼
- if not exist "%rsynchome%" (
- :: ԱȨ
- echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\runAsAdmin.vbs"
- echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\runAsAdmin.vbs"
- "%temp%\runAsAdmin.vbs"
- :: ҪԱȨܴĿ¼
- mkdir "%rsynchome%"
- del "%temp%\runAsAdmin.vbs"
- exit /B
- )
-
- :: ʹpowershellcurl
- powershell curl -o %temp%\%zipfile% %downurl%
- :: ѹ
- tar -xf "%temp%\%zipfile%" -C "%rsynchome%"
- echo "%cmdstr%Ѿװ%rsynchome%Ŀ¼"
-
- :: ·Ƿ PATH
- set "found=false"
- for %%I in ("%PATH:;=";"%") do (
- if /I "%%~I"=="%rsynchome%\bin" (
- set "found=true"
- )
- )
-
- :: δõpathУӵpath
- if "!found!"=="false" (
- :: עе PATH ͨsetxʽֵȳ1024ַͻᱻض
- reg add "HKCU\Environment" /v PATH /t REG_EXPAND_SZ /d "%PATH%;%rsynchome%\bin" /f
- )
-
- )
-
- ::ǰĿ¼ûdistĿ¼
- if not exist "%currpath%%syncdir%" (
- echo ǰĿ¼ûҪͬ%syncdir%Ŀ¼Ҫͬ%syncdir%Ŀ¼ǰĿ¼£
- ) else (
- echo !password!>%passfile%
- echo ͬʼԺ...
- !runcommand! && (
- echo ͬ!
- ) || (
- echo !runcommand!
- echo ͬʧܣȷǷVPN
- )
- del %passfile%
- )
-
- endlocal
- pause
|