Check network connection with VBScript

前端 未结 2 664
北荒
北荒 2020-12-10 19:33

I\'m running a web-based slideshow on multiple computer units. I have a VBScript that runs on startup, opens IE and navigates to a specific page in fullscreen mode. Everythi

2条回答
  •  萌比男神i
    2020-12-10 20:30

    Refer to this ==> Loop a function?

    Yes, you can do it easily with this code :

    Option Explicit
    Dim MyLoop,strComputer,objPing,objStatus
    MyLoop = True
    While MyLoop = True
        strComputer = "smtp.gmail.com"
        Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}!\\").ExecQuery _
        ("select * from Win32_PingStatus where address = '" & strComputer & "'")
        For Each objStatus in objPing
            If objStatus.Statuscode = 0 Then
                MyLoop = False
                Call MyProgram()
                wscript.quit
            End If
        Next
        Pause(10) 'To sleep for 10 secondes
    Wend
    '**********************************************************************************************
     Sub Pause(NSeconds)
        Wscript.Sleep(NSeconds*1000)
     End Sub
    '**********************************************************************************************
    Sub MyProgram()
    Dim WshShell
    set WshShell = WScript.CreateObject("WScript.Shell")         
    On Error Resume Next
       With WScript.CreateObject ("InternetExplorer.Application")     
          .Navigate "http://www.example.com/slideshow"
          .fullscreen = 1   
          .Visible    = 1
          WScript.Sleep 10000
       End With    
    On Error Goto 0
    End Sub
    '**********************************************************************************************
    

提交回复
热议问题