auto updater of new releases
Moderator: DosItHelp
auto updater of new releases
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!
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
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
Create a batch file with the following line only.
Code: Select all
@echo "%~t0"|clip
Steffen
Re: auto updater of new releases
"31.03.2019 17:52"
Re: auto updater of new releases
Give that a go.
To avoid problems remember that paths on Windows are separated with backward slashes instead of forward slashes.
Steffen
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%"
Steffen
Re: auto updater of new releases
works like a charm!
many thanks!
many thanks!
Re: auto updater of new releases
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"
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
Something like
Code: Select all
if not exist "c:\foo\bar.exe" ...
The second FOR loop defines variable recent_file that you should use to copy the file then.then jsut download the file from the remote directory?
You could map a network drive using NET USE. Refer to+ 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"
https://docs.microsoft.com/en-us/previo ... 5(v=ws.11)
Steffen
Re: auto updater of new releases
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
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
I can't log in to this link!?aGerman wrote: ↑03 Aug 2020 14:11Something likeCode: Select all
if not exist "c:\foo\bar.exe" ...
The second FOR loop defines variable recent_file that you should use to copy the file then.then jsut download the file from the remote directory?
You could map a network drive using NET USE. Refer to+ 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"
https://docs.microsoft.com/en-us/previo ... 5(v=ws.11)
Steffen
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: auto updater of new releases
You shouldn't have to log into it at all, but it's the same content as https://ss64.com/nt/net-use.html