Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBScript CreateObject Google Chrome

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
like image 513
Mowgli Avatar asked Jan 08 '13 20:01

Mowgli


People also ask

Can Chrome run VBScript?

VBScript does not support all modern browsers. VBScript is supported by Internet Explorer of Microsoft only, while other browsers (Firefox and Chrome) offer JavaScript support.

What is Wscript CreateObject?

CreateObject Method The CreateObject method creates a new instance of a specified COM object. Once the object has been successfully created, you can access any properties or call any methods the object exposes. Its syntax is: Set objObject = Wscript.CreateObject( strObjectId )


2 Answers

It's because Chrome does not support VBScript. See http://productforums.google.com/forum/#!category-topic/chrome/give-feature-feedback-and-suggestions/xHWNXByKdhM

like image 163
Alexander Pavlov Avatar answered Oct 10 '22 02:10

Alexander Pavlov


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}"
like image 34
Sanke Avatar answered Oct 10 '22 03:10

Sanke