我们可以写如下代码:
Option Explicit Dim objIE Const READYSTATE_COMPLETE = 4 'As Long Const OLECMDID_ZOOM = 19 'As Long Const OLECMDEXECOPT_DONTPROMPTUSER = 2 'As Long Const URL = "http://localhost:8080/imart/default.portal" 'As String Set objIE = CreateObject("InternetExplorer.Application") '创建IE对象 With objIE '' 跳转到指定的url .Navigate2 URL Do While .ReadyState <> READYSTATE_COMPLETE : Loop .Left = fix((objIE.document.parentwindow.screen.availwidth-objIE.width)/2) '水平居中' .Top = fix((objIE.document.parentwindow.screen.availheight-objIE.height)/2) '垂直居中' .Width = 1024 .Height = 768 .ToolBar = False 'ToolBar On/Off .MenuBar = False 'MenuBar On/Off .ResizAble = False .AddressBar = False .Statusbar=True ''是否在IE中显示 .Visible = False .ExecWB OLECMDID_ZOOM,OLECMDEXECOPT_DONTPROMPTUSER, CLng(2), Null End With
然后保存上面代码为以vbs为后缀名的文件,点击该文件就可以打开指定的网址。