69 lines
2.0 KiB
Batchfile
69 lines
2.0 KiB
Batchfile
|
@echo off
|
|||
|
setlocal enabledelayedexpansion
|
|||
|
set cmdstr=rsync
|
|||
|
set zipfile=cwrsync.zip
|
|||
|
set downurl=https://itefix.net/download/free/cwrsync_6.3.0_x64_free.zip
|
|||
|
set currpath=%~dp0
|
|||
|
set "rsynchome=%ProgramFiles%\%zipfile:~0,-4%"
|
|||
|
set passfile=%temp%\.password
|
|||
|
set syncdir=dist/
|
|||
|
:: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
set accountwithost=kszny@47.96.93.140::mes2
|
|||
|
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
|
|||
|
::<3A>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڸ<EFBFBD><DAB8><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
if %errorlevel% neq 0 (
|
|||
|
::<3A><>δ<EFBFBD><CEB4><EFBFBD>ذ<EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>װĿ¼
|
|||
|
if not exist "%rsynchome%" (
|
|||
|
:: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԱȨ<D4B1><C8A8>
|
|||
|
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\runAsAdmin.vbs"
|
|||
|
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\runAsAdmin.vbs"
|
|||
|
"%temp%\runAsAdmin.vbs"
|
|||
|
:: <20><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԱȨ<D4B1><EFBFBD><DEB2>ܴ<EFBFBD><DCB4><EFBFBD><EFBFBD><EFBFBD>Ŀ¼
|
|||
|
mkdir "%rsynchome%"
|
|||
|
del "%temp%\runAsAdmin.vbs"
|
|||
|
exit /B
|
|||
|
)
|
|||
|
|
|||
|
:: ʹ<><CAB9>powershell<6C><6C>curl<72><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
powershell curl -o %temp%\%zipfile% %downurl%
|
|||
|
:: <20><>ѹ
|
|||
|
tar -xf "%temp%\%zipfile%" -C "%rsynchome%"
|
|||
|
echo "%cmdstr%<EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>%rsynchome%Ŀ¼<EFBFBD><EFBFBD>"
|
|||
|
|
|||
|
:: <20><><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> PATH <20><>
|
|||
|
set "found=false"
|
|||
|
for %%I in ("%PATH:;=";"%") do (
|
|||
|
if /I "%%~I"=="%rsynchome%\bin" (
|
|||
|
set "found=true"
|
|||
|
)
|
|||
|
)
|
|||
|
|
|||
|
:: δ<><CEB4><EFBFBD>õ<EFBFBD>path<74><68><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD>ӵ<EFBFBD>path<74><68><EFBFBD><EFBFBD>
|
|||
|
if "!found!"=="false" (
|
|||
|
:: <20><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD> PATH <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>setx<74><78>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>ȳ<EFBFBD><C8B3><EFBFBD>1024<32><34><EFBFBD>ַ<EFBFBD><D6B7>ͻᱻ<CDBB>ض<EFBFBD>
|
|||
|
reg add "HKCU\Environment" /v PATH /t REG_EXPAND_SZ /d "%PATH%;%rsynchome%\bin" /f
|
|||
|
)
|
|||
|
|
|||
|
)
|
|||
|
|
|||
|
::<3A><>ǰĿ¼<C4BF><C2BC>û<EFBFBD><C3BB>distĿ¼
|
|||
|
if not exist "%currpath%%syncdir%" (
|
|||
|
echo <20><>ǰĿ¼<C4BF><C2BC>û<EFBFBD><C3BB><EFBFBD><EFBFBD>Ҫͬ<D2AA><CDAC><EFBFBD><EFBFBD>%syncdir%Ŀ¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>%syncdir%Ŀ¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰĿ¼<EFBFBD>£<EFBFBD>
|
|||
|
) else (
|
|||
|
echo !password!>%passfile%
|
|||
|
echo <20><><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD>...
|
|||
|
!runcommand! && (
|
|||
|
echo <20><><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!
|
|||
|
) || (
|
|||
|
echo !runcommand!
|
|||
|
echo <20><><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>VPN<50><4E>
|
|||
|
)
|
|||
|
del %passfile%
|
|||
|
)
|
|||
|
|
|||
|
endlocal
|
|||
|
pause
|