Link to home
Start Free TrialLog in
Avatar of Aryabhatta M
Aryabhatta M

asked on

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
Avatar of Qlemo
Qlemo
Flag of Germany image

You would have to use tools to do that with a batch file. However, PowerShell can get control over a web pages it starts.
Avatar of Bill Prew
Bill Prew

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...


»bp
PowerShell (pure VBS would require similar code):
$ie = New-Object -Com InternetExplorer.Application
$ie.Navigate("http://localhost:$($env:NewPort)/MyProject")
$ie.Visible = $true
foreach ($I in 1..3)
{
  start-sleep 7
  $ie.Refresh()
}

Open in new window

Avatar of Aryabhatta M

ASKER

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 ?
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Helpful knowledge shared. Thank you.