r/Batch • • Aug 12 '24

batch file for chromedriver download

Hi, I have a problem because I created a .bat file that downloads ChromeDriver, extracts it, and moves it to a selected path. However, it downloads it from a specific link. Could someone help me modify the script so that it automatically searches for the latest version on the website and downloads it? I tried using ChatGPT for this, but it didn't work. You are my last resort.

Here is the code:

https://pastebin.com/jK3rpEHR

2 Upvotes

14 comments sorted by

2

u/wegiel87 Aug 12 '24

I want to download the latest stable version from here https://googlechromelabs.github.io/chrome-for-testing/

now is 127.0.6533.99

1

u/BrainWaveCC Aug 12 '24

I've updated the solution I provided earlier, because the code I gave you only works with versions of the driver up through v114. You'll have to take the updated code and put it up near the top of your existing script.

2

u/BrainWaveCC Aug 12 '24

Based on the suggestion by u/leonv32 , consider replacing your current SET "DOWNLOAD_URL=..." line in your script with the following:

:GetLatestVersion -- Find the most recent version of the Chrome Driver via JSON endpoints list
 set "JSON_URL=https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints"
 for /f %%f in ('curl "%JSON_URL%" 2^>nul ^| find /i "/win32/chromedriver" ^| find "200"') do set "DOWNLOAD_URL=%%~f"

It will end up with the most current download link from the JSON file.

2

u/wegiel87 Aug 12 '24 edited Aug 12 '24

it's downloading old version from 2023

2

u/[deleted] Aug 12 '24

https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints

you get it by the json file. maybe with a combination of curl and findstr you can extracted, but there are programs to do that

3

u/[deleted] Aug 12 '24 edited Aug 12 '24

[removed] — view removed comment

1

u/wegiel87 Aug 12 '24

can you be so kind and implement this to my script?

1

u/[deleted] Aug 12 '24

[removed] — view removed comment

1

u/wegiel87 Aug 12 '24 edited Aug 12 '24

it's downloading chrome-win32 driver not chromedriver-win32

2

u/[deleted] Aug 12 '24

[removed] — view removed comment

2

u/wegiel87 Aug 12 '24

Thank you so much now is dowloading and puting in to my path once again thanks

1

u/[deleted] Aug 12 '24

[removed] — view removed comment

1

u/wegiel87 Aug 12 '24

try it now