2008年2月6日水曜日

[VBScript]インターネットエクスプローラでWebページを開きます。

Option Explicit

'===============================================================================
'
' 名称: OpenIE
'
' 説明: sURLを開く
'
' 引数: sURL
'
' 戻り値: 成功...True 失敗...True
'
'===============================================================================
Function OpenIE(sURL)

Dim oIE
Dim oShell

OpenIE = False

Set oIE = WScript.CreateObject("InternetExplorer.Application")
Set oShell = WScript.CreateObject("WScript.Shell")

With oIE
.Visible = True

On Error Resume Next
.Navigate(sURL)

If Err.Number <> 0 Then
Call oShell.LogEvent( 1, Err.Number & " " & Err.Description )
Err.Clear
Exit Function
End If

On Error GoTo 0

Do While .Busy = True
WScript.Sleep( 100 )
Loop

End With

Set oShell = Nothing
Set oIE = Nothing

OpenIE = True

End Function

Const cURL = "http://www.yahoo.co.jp"

If OpenIE(cURL) Then
WScript.Echo("成功")
Else
WScript.Echo("失敗")
End If

0 件のコメント: