In a Batch script how to refresh webpage after launching in default browser

I want to refresh the launched webpage just 3 times in an interval of 7 seconds after webpage is launched by the below script. How can I do that? ( This refresh is required for the application to load properly)

@echo Launching application in webpage
start http://localhost:%NewPort%/MyProject
Aryabhatta MAsked:
Who is Participating?
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
The above is PowerShell code, and belongs into a .PS1 file.

The parameter NewPort is expected as an environment variable already set - exactly as in the batch file.

Calling would work  with powershell -ExecutionPolicy Bypass -File .\Launch.ps1 .

For automation IE is required. Each browser uses its own API to get access to the internal stuff to work with. Using the default browser and sending keys is possible (in PS or VBS) but very unreliable, in particular when having to add delays.
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
You would have to use tools to do that with a batch file. However, PowerShell can get control over a web pages it starts.
Bill PrewCommented:
And you could run a VBscript from the BAT file to do the load of the web page and refreshes, but that isn't much different than the Powershell approach mentioned above...

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

QlemoBatchelor, Developer and EE Topic AdvisorCommented:
PowerShell (pure VBS would require similar code):
$ie = New-Object -Com InternetExplorer.Application
$ie.Visible = $true
foreach ($I in 1..3)
  start-sleep 7

Open in new window

Aryabhatta MAuthor Commented:
Thanks Qlemo and Bill, I have some doubts and need help in executing it -

[1] (a) Can I save the above code as Launch.vbs in same folder and call it from my batch file like => call "%~dp0\Launch.vbs . Will it work ?
(b) How will I pass the variable value of %NewPort% from batch to this VBS code.

[2]I want to do it for default browser whatever is set in users PC, it may be IE or Mozilla or Chrome.
[Is there any simple way like send keys with f5 and doing some delay in between ? If that is possible how can I write it ?
Aryabhatta MAuthor Commented:
Helpful knowledge shared. Thank you.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.