Update autoupdate.bat

code optimization: speedup the file streaming by 600%
This commit is contained in:
asmtron 2019-08-13 17:26:08 +00:00 committed by GitHub
parent b0e5caada7
commit f79998c217
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 20 deletions

View File

@ -7,7 +7,7 @@ REM -------------------------------------------------------------------
REM REM
REM autoupdate.bat REM autoupdate.bat
REM REM
REM Automatic RDP Wrapper installer and updater // asmtron (15-08-2019) REM Automatic RDP Wrapper installer and updater // asmtron (16-08-2019)
REM ------------------------------------------------------------------- REM -------------------------------------------------------------------
REM Options: REM Options:
REM -log = redirect display output to the file autoupdate.log REM -log = redirect display output to the file autoupdate.log
@ -214,31 +214,23 @@ REM -------------------
if %rdpwrap_installed%=="0" ( if %rdpwrap_installed%=="0" (
call :install call :install
) )
REM NOTE normal copy of the file "rdpwrap_new.ini" to "rdpwrap.ini" will not work (file locked) REM NOTE - normal copy of the file "rdpwrap_new.ini" to "rdpwrap.ini" will not work (file locked)
REM we need to stream the data line by line from "rdpwrap_new.ini" to "rdpwrap.ini" REM we need to stream the data from "rdpwrap_new.ini" to "rdpwrap.ini"
if exist %rdpwrap_new_ini% ( if exist %rdpwrap_new_ini% (
echo [*] Start streaming %rdpwrap_new_ini% to %rdpwrap_ini%... echo [*] Start streaming %rdpwrap_new_ini% to %rdpwrap_ini%...
set firstline="0" (
for /f "usebackq delims=" %%a in ( for /f "usebackq delims=" %%a in (
`findstr /n "^" %rdpwrap_new_ini%` `findstr /n "^" %rdpwrap_new_ini%`
) do ( ) do (
set "line=!%%a!" set "line=!%%a!"
set "line=!line:*:=!" set "line=!line:*:=!"
if !firstline!=="0" (
set firstline="1"
if "!line!"=="*:=" ( if "!line!"=="*:=" (
echo.>%rdpwrap_ini% echo.
) else ( ) else (
echo !line!>%rdpwrap_ini% echo !line!
)
) else (
if "!line!"=="*:=" (
echo.>>%rdpwrap_ini%
) else (
echo !line!>>%rdpwrap_ini%
) )
) )
) )>%rdpwrap_ini%
echo [+] Update of %rdpwrap_ini% finished successfully. echo [+] Update of %rdpwrap_ini% finished successfully.
) )
echo. echo.