i have a code to login to a site every 15 minutes (set to five seconds for testing) in google chrome. It needs to be logged in in order for me to use internet. in its current form, every fifteen minutes it opens another chrome browser and logs in and keeps the browser alive (its needed) after fifteen minutes it creates one more chrome browser and it continues. what i would like to do is, the second time it opens i want the first chrome browser closed. ie any any given time besides the one i am using there should only be one more window.
the current code is
foundProc = true
do while foundProc = true
wscript.sleep (5000)
foundProc = False
procName = "chrome.exe"
procNameFriend = "Chrome"
for each Process in objWMIService.InstancesOf ("Win32_Process")
If StrComp(Process.Name,procName,vbTextCompare) = 0 then
foundProc = true
End If
Next
If foundProc = True Then 'if chrome is open logging in to the site
Shell.Run("chrome.exe")
wscript.sleep (500)
shell.SendKeys "<login site>"
shell.SendKeys "blah blah blah" 'now logged in
wscript.sleep (2500)
'wscript.sleep (1000)
shell.SendKeys "%{TAB}" ' alt tab to return to current window
End If
loop