VBS going to a URL in the background

前端 未结 2 1627
鱼传尺愫
鱼传尺愫 2021-01-27 00:38

I would like to have my VB script go to a URL in the background. It can open a browser in the background and close it afterwards. The more \"silent\" the better. I had 2 impl

相关标签:
2条回答
  • 2021-01-27 00:58
    Set WshShell = WScript.CreateObject("WScript.Shell") 
    Return = WshShell.Run("iexplore.exe " &  myURL, 1) 
    WScript.Sleep 10000
    WshShell.SendKeys "{F6}"
    WScript.Sleep 500
    WshShell.SendKeys "y"
    WScript.Sleep 500
    WshShell.SendKeys "o"
    WScript.Sleep 500
    WshShell.SendKeys "u"
    WScript.Sleep 500
    WshShell.SendKeys "t"
    WScript.Sleep 500
    WshShell.SendKeys "u"
    WScript.Sleep 500
    WshShell.SendKeys "b"
    WScript.Sleep 500
    WshShell.SendKeys "e"
    WScript.Sleep 500
    WshShell.SendKeys "{ENTER}"
    WScript.Sleep 500
    
    0 讨论(0)
  • 2021-01-27 01:09

    If you're looking for a silent approach I'd suggest to drop the Internet Explorer COM object entirely and go for an XMLHttpRequest object:

    myURL = "http://www.google.com/"
    
    Set req = CreateObject("MSXML2.XMLHTTP.6.0")
    req.Open "GET", myURL, False
    req.Send
    
    WScript.Echo req.ResponseText
    
    0 讨论(0)
提交回复
热议问题