Page 1 of 1
auto updater of new releases
Posted: 30 Mar 2019 09:48
by shokarta
Hello guys,
first I have to appologize, I have zero experience with batch scripting, however it look similar to other languages...
I would like to kindly ask for your help developing a very simple couple row script, whic basicaly should do:
1) check the directory (for example C:/Terminal/NewReleases/) and go through every exe files in that directory
2) in case there is newer (compare by date) exe file in that directory in compare to C:/Terminal/terminal.exe then copy the newer file (whatever its named) to C:/Terminal/ and overwrite to terminal.exe
3) once its done, just run terminal.exe
Note: this bat file will be located in C:/Terminal, therefore maybe dont refer to absolute directory (C:/Terminal) but instead recall somehow CURRENTDIRECTORY
Howver the C:/Terminal/NewReleases is just an exmpale of the folder, it can change anytime to some network remote harddrive, therefore this path should stay as absolute...
So if the directory to check for new releases is not available, then just skip and run the terminal.exe from C:/Terminal
Thank oyu guys!
Re: auto updater of new releases
Posted: 31 Mar 2019 08:49
by aGerman
The date format is dependent on local settings. In order to be able to compare it, we need to know how it looks like on your computer.
Create a batch file with the following line only.
Run it once. Date and time of the batch script will be copied to the clipboard. Paste it into your next reply.
Steffen
Re: auto updater of new releases
Posted: 31 Mar 2019 09:53
by shokarta
"31.03.2019 17:52"
Re: auto updater of new releases
Posted: 31 Mar 2019 10:55
by aGerman
Give that a go.
Code: Select all
@echo off &setlocal
set "release_path=C:\Terminal\NewReleases"
set "file_name=terminal.exe"
pushd "%release_path%"
for %%i in ("%~dp0%file_name%") do for /f "tokens=1-5 delims=.: " %%j in ("%%~ti") do set "current_time=%%l%%k%%j%%m%%n"
for /f "delims=" %%i in ('dir /a-d /b /od *.exe') do (set "recent_time=%%~ti"&set "recent_file=%%~i")
for /f "tokens=1-5 delims=.: " %%j in ("%recent_time%") do set "recent_time=%%l%%k%%j%%m%%n"
if "%recent_time%" gtr "%current_time%" copy /y "%recent_file%" "%~dp0%file_name%"
popd
start "" "%file_name%"
To avoid problems remember that paths on Windows are separated with backward slashes instead of forward slashes.
Steffen
Re: auto updater of new releases
Posted: 31 Mar 2019 22:24
by shokarta
works like a charm!
many thanks!
Re: auto updater of new releases
Posted: 27 Jul 2020 01:05
by shokarta
Hello,
i know this is quite a long time,
But I have found, that if the file terminal.exe doesnt exist, all script stops on this…
Is it posisble to modify to check if the file localy exists, and if not then jsut download the file from the remote directory?
+ also, would be possible to add credential check?
for some remote folders where security allows only some users, i have the error of "Invalid username or password" and when opening the dir in explorer the Windows pops up the credentials window.
- so would be possible to open the directory with credentials?
maybe something like:
set "release_path=\\username:password@some_remote_location\direktory\terminal.exe"
Re: auto updater of new releases
Posted: 03 Aug 2020 14:11
by aGerman
shokarta wrote: ↑27 Jul 2020 01:05
Is it posisble to modify to check if the file localy exists, and if not ...
Something like
then jsut download the file from the remote directory?
The second FOR loop defines variable recent_file that you should use to copy the file then.
+ also, would be possible to add credential check?
for some remote folders where security allows only some users, i have the error of "Invalid username or password" and when opening the dir in explorer the Windows pops up the credentials window.
- so would be possible to open the directory with credentials?
maybe something like:
set "release_path=\\username:password@some_remote_location\direktory\terminal.exe"
You could map a network drive using NET USE. Refer to
https://docs.microsoft.com/en-us/previo ... 5(v=ws.11)
Steffen
Re: auto updater of new releases
Posted: 20 Aug 2020 00:09
by shokarta
Hello Steffen,
would you mind if I kindly ask you to implement it into the initial batch script from you so its all together checked by you?
If I would do it, most likely there would be some unlogical syntax issue and I would be caming back to you few times before it would be working
Thank you for the best support
Re: auto updater of new releases
Posted: 20 Aug 2020 08:54
by AdamsLor
aGerman wrote: ↑03 Aug 2020 14:11
shokarta wrote: ↑27 Jul 2020 01:05
Is it posisble to modify to check if the file localy exists, and if not ...
Something like
then jsut download the file from the remote directory?
The second FOR loop defines variable recent_file that you should use to copy the file then.
+ also, would be possible to add credential check?
for some remote folders where security allows only some users, i have the error of "Invalid username or password" and when opening the dir in explorer the Windows pops up the credentials window.
- so would be possible to open the directory with credentials?
maybe something like:
set "release_path=\\username:password@some_remote_location\direktory\terminal.exe"
You could map a network drive using NET USE. Refer to
https://docs.microsoft.com/en-us/previo ... 5(v=ws.11)
Steffen
I can't log in to this link!?
Re: auto updater of new releases
Posted: 20 Aug 2020 13:48
by ShadowThief
You shouldn't have to log into it at all, but it's the same content as
https://ss64.com/nt/net-use.html