Here is my 'auto-update script', feel free to use it

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
LogicDaemon
Junior Member
Junior Member
Posts: 20
Joined: 2012-07-29, 18:12 UTC
Location: Russia
Contact:

Here is my 'auto-update script', feel free to use it

Post by *LogicDaemon »

I've just written a script for auto-updating the TC. It gets current version from [TXT] releaseversion.ghisler.com and uses curl to download it (get official curl for Windows from https://curl.haxx.se/download.html).

Feel free to use, modify, ask questions or give suggestions :)

https://pastebin.com/wJQjbS5M

Code: Select all

@(REM coding:CP866
REM by LogicDaemon <www.logicdaemon.ru>
REM This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License <http://creativecommons.org/licenses/by-sa/4.0/deed.ru>.
SETLOCAL ENABLEEXTENSIONS
IF "%~dp0"=="" (SET "srcpath=%CD%\") ELSE SET "srcpath=%~dp0"
IF NOT DEFINED PROGRAMDATA SET "PROGRAMDATA=%ALLUSERSPROFILE%\Application Data"
IF NOT DEFINED APPDATA IF EXIST "%USERPROFILE%\Application Data" SET "APPDATA=%USERPROFILE%\Application Data"
    
    SET "dirData=%~dp0"
    SET "dirDist=%~dp0"
    SET "dirDlTmp=%~dp0temp\"
    SET "installOptns=/A1H0L1M0G0D0U1K0" & REM https://www.ghisler.ch/wiki/index.php?title=How_to_make_installation_fully_automatic%3F
    SET "dlcmdPrefix=curl.exe -OJLR"
    SET "dlcmdSuffix= || EXIT /B"
    
    FOR /F "usebackq skip=3" %%A IN (`"%SystemRoot%\System32\nslookup.exe -type=txt releaseversion.ghisler.com"`) DO IF NOT "%%~A"=="" SET "newtcver=%%~A"
    IF NOT DEFINED newtcver EXIT /B 1
    FOR /F "usebackq delims=" %%A IN ("%dirData%oldver.txt") DO SET "oldtcver=%%~A"
)
(
    IF "%newtcver%"=="%oldtcver%" EXIT /B 0
    (ECHO %newtcver%)>"%dirData%newver.txt"
    
    FOR /F "delims=.; tokens=1,2,3,4,5" %%A IN ("%newtcver%") DO (
	SET "verComponent1=%%~A"
	SET "verComponent2=%%~B"
	SET "verComponent3=%%~C"
	SET "verComponent4=%%~D"
	SET "verComponent5=%%~E"
    )
)
(
    MKDIR "%dirDlTmp%"
    rem %dlcmdPrefix% http://totalcommander.ch/win/tcmd%verComponent2%%verComponent3%x32.exe %dlcmdSuffix%
    rem %dlcmdPrefix% http://totalcommander.ch/win/tcmd%verComponent2%%verComponent3%x64.exe %dlcmdSuffix%
    START "" /B /WAIT /D "%dirDlTmp%" %dlcmdPrefix% http://totalcommander.ch/win/tcmd%verComponent2%%verComponent3%x32_64.exe %dlcmdSuffix%
    FOR %%A IN ("%dirDlTmp%\*.*") DO (
	MOVE /Y "%%~A" "%dirDist%"
	"%dirDist%\%%~nxA" %installOptns%
    )
    
    MOVE /Y "%dirData%newver.txt" "%dirData%oldver.txt"
    EXIT /B
)

Last edited by LogicDaemon on 2019-08-30, 12:35 UTC, edited 1 time in total.
Alexisback
Junior Member
Junior Member
Posts: 80
Joined: 2016-10-26, 20:04 UTC

Post by *Alexisback »

:D спасибо LogicDaemon
очень полезно

:) thank you
very helpful
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48028
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

The TXT field on releaseversion.ghisler.com has the following possible contents:
10.9.12.0
10.9.12.0;3

The 10. part is always the same. Then comes the major and minor version. The last part is 1 for a, 2 for b etc. releaseversion.ghisler.com is no longer used for announcing beta versions. You can query releasebeta.ghisler.com for that. The ;3 tells TC to check for updates every 3 days. I set a number >1 when no release is in sight, to reduce the server load. Currently it's still set to ;1 which means check every day.

Here the last digit is different: 129 is beta 1, 130 beta 2 etc. 229 is release candidate 1, 230 is release candidate 2 etc.
Author of Total Commander
https://www.ghisler.com
Post Reply