6
votes

I have this VBScript it works fine, no problem with script but I would like to open it in Chrome instead of IE.

I am very very new to VB Scripting. Can someone please help me.

WScript.Quit Main

Function Main
  Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
  IE.Visible = True
  IE.Navigate "http://gmail.com"
  Wait IE
  With IE.Document
    .getElementByID("login_username").value = "myuser"
    .getElementByID("login_password").value = "mypass"
    .getElementByID("frmLogin").submit
  End With
End Function

Sub Wait(IE)
  Do
    WScript.Sleep 500
  Loop While IE.ReadyState < 4 And IE.Busy 
  Do
    WScript.Sleep 500
  Loop While IE.ReadyState < 4 And IE.Busy 
End Sub

Sub IE_OnQuit
  On Error Resume Next
  WScript.StdErr.WriteLine "IE closed before script finished."
  WScript.Quit
End Sub
3
You might be able to use Google Chrome Frame, ie CreateObject("ChromeTab.ChromeFrame") but it's a long shot - user69820
@oraclecertifiedprofessional: This looks like an answer, not a comment. - Helen
@Helen only if it works, I have not tried it - user69820
@oraclecertifiedprofessional that didn't work either. I will need to work on writing this code in JSCRIPT. - Mowgli
related: stackoverflow.com/q/14328348/69820 - user69820

3 Answers

2
votes

Have a look at the code. There is the code for starting chrome

  set WshShell=WScript.CreateObject("WScript.Shell")
   strAnswer = InputBox("Please enter a name for your new file:")
   WshShell.run "chrome.exe"
   WScript.sleep 100
   WshShell.sendkeys "www.google.com" 
   WshShell.sendkeys "{ENTER}"
0
votes

'unfortunately, you can only open some urls, you can't control it like internet explorer

dim objApp : set objApp=createobject("Shell.application") objApp.Shellexecute"chrome.exe","www.google.com","","", 1