1

我有一个无法解决的问题,对于专家来说,解决方案可能非常简单。即使借助 stackoverflow 和其他一些脚本论坛上的现有帖子,我也没有设法让它工作。

所以我的目标是让我的简单脚本(我将其用作演示文稿)在出现任何错误时自行重置。我已经尝试过'on error resume next',但这只是让我的电脑一遍又一遍地启动 IE。

所以我的目标是在出现错误后让我的脚本继续运行。如果我的问题惹恼了任何人,请告诉我,我会自行更改或自行调整(视情况而定)。

我的脚本:

执行“下一个错误恢复”

Set objIE = CreateObject("InternetExplorer.Application")
objIE.Visible = 1
objIE.FullScreen=True
objIE.Navigate "About:Blank"



Do Until VarType(objIE) = 9
    WScript.Sleep 4000
    objIE.Navigate "local URL"

    WScript.Sleep 6000
    objIE.Navigate "local URL"

        WScript.Sleep 10000
    objIE.Navigate "URL"


        WScript.Sleep 8000
        objIE.Navigate "URL"

        WScript.Sleep 8000
        objIE.Navigate "URL"

                      WScript.Sleep 12000
        objIE.Navigate "URL"

        WScript.Sleep 10000
        objIE.Navigate "URL"

        WScript.Sleep 14000
        objIE.Navigate "URL"

            WScript.Sleep 14000
        objIE.Navigate "URL"


Loop

环形

4

1 回答 1

0

此脚本不会结束,您必须终止 wscript 进程才能停止它。它检查系统上所有正在运行的进程是否有“iexplore”;如果未找到 Internet Explorer,则脚本将启动一个新实例。如果找到 iexplore,它会发送导航命令。

On Error Resume Next 

Do While true
If Check() = true Then
    WScript.Sleep 4000
    objIE.Navigate "local URL"

    WScript.Sleep 6000
    objIE.Navigate "local URL"

    WScript.Sleep 10000
    objIE.Navigate "URL"

    WScript.Sleep 8000
    objIE.Navigate "URL"

    WScript.Sleep 8000
    objIE.Navigate "URL"

    WScript.Sleep 12000
    objIE.Navigate "URL"

    WScript.Sleep 10000
    objIE.Navigate "URL"

    WScript.Sleep 14000
    objIE.Navigate "URL"

    WScript.Sleep 14000
    objIE.Navigate "URL"
End If
If Check() = false Then
    'Start Iexplore and direct it to blank page
    Set objIE = CreateObject("InternetExplorer.Application")
    objIE.Visible = 1
    objIE.FullScreen=True
    objIE.Navigate "About:Blank"
End If


Loop

'Check to see if IEXPLORE is running
Function Check()
Dim objWMIService, objProcess, colProcess
Dim strComputer, strList
strComputer = "."

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process")

For Each objProcess in colProcess
    If (inStr(objProcess.Name, "iexplore")) then
        Check = true
    Else
        Check = false
    End If
Next
End Function
于 2013-06-04T17:20:33.793 回答