Edge VB Script to load page and clear cache

Gary Ray 1 Reputation point
2021-10-07T09:22:55.223+00:00

I am trying to figure out how to do a VB script to load a page on Edge and then clear the cache.

So far I can get the page to load but cannot find the cache part.

Set objShell = CreateObject("WScript.Shell")
objShell.Run "msedge http://ceto/dhms/login.aspx"

Please advise

Microsoft Edge
Microsoft Edge
A Microsoft cross-platform web browser that provides privacy, learning, and accessibility tools.
2,234 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,663 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yu Zhou-MSFT 12,951 Reputation points Microsoft Vendor
    2021-10-08T09:26:34.63+00:00

    Hi @Gary Ray

    You can achieve what you want using Seleniumbasic. Seleniumbasic is a Selenium based browser automation framework for VB.Net , VBA and VBScript. Before writing the code, there're some steps needing to be followed:

    1. Download the latest version of SeleniumBasic v2.0.9.0 from this link and install it.
    2. Download the corresponding version of Edge WebDriver from this link.
    3. Find the path of SeleniumBasic which is C:\Users\%username%\AppData\Local\SeleniumBasic in my situation (it might also be in this path C:\Program Files\SeleniumBasic), copy the Edge WebDriver msedgedriver.exe to this path.
    4. Rename msedgedriver.exe to edgedriver.exe.

    The VBScript code is like below. You can first open Edge, then navigate to edge://settings/clearBrowserData and automate the browser to clear the cache:

    Dim driver  
      
    Set driver = CreateObject("Selenium.EdgeDriver")  
    driver.Get "https://www.google.com"  
    driver.Wait 5000  
    driver.Get "edge://settings/clearBrowserData"  
    driver.FindElementById("clear-now").Click  
    driver.Wait 5000  
    driver.Quit  
    

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Regards,
    Yu Zhou