1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| Option Explicit
Dim Boucle,strComputer,MsgTitre,objPing,objStatus
Boucle = True
While Boucle = True
strComputer = "smtp.gmail.com"
MsgTitre = "TEST DE CONNEXION INTERNET ET SMTP DE GMAIL"
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}!\\").ExecQuery("select * from Win32_PingStatus where address = '" & strComputer & "'")
For Each objStatus in objPing
If objStatus.Statuscode = 0 Then
msgbox "TEST SMTP DE GMAIL EST OK . VOUS ETES CONNECTE A INTERNET ET LE SMTP DE GMAIL EST DISPONIBLE ! " & objStatus.Statuscode,64,MsgTitre
Boucle = False
Call Ip_Publique
wscript.quit
else
msgbox "TEST SMTP DE GMAIL EST NO OK . VOUS N'ETES PAS CONNECTE A INTERNET ET LE SMTP DE GMAIL N'EST PLUS DISPONIBLE EN CE MOMENT !" & objStatus.Statuscode,16,MsgTitre
End If
Call ReNewLocalIP
Next
wscript.sleep 60000
Wend
Sub Ip_Publique
Dim Titre,URL,ie,objFSO,Data,OutPut,objRegex,Match,Matches
Titre = "Adresse Ip Publique !"
URL = "http://monip.org"
Set ie = CreateObject("InternetExplorer.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
ie.Navigate (URL)
ie.Visible=false
DO WHILE ie.busy
wscript.sleep 100
LOOP
Data = ie.document.documentElement.innertext
'MsgBox Data,64,Titre
Set OutPut = objfso.OpenTextFile("monip.txt",8,True)
ie.Quit
Set ie = Nothing
Set objRegex = new RegExp
objRegex.Pattern = "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b"
objRegex.Global = False
objRegex.IgnoreCase = True
Set Matches = objRegex.Execute(Data)
For Each Match in Matches
MsgBox "Mon IP Publique est : " & vbCr & Match.Value ,64,Titre
OutPut.WriteLine string(40,"-") & vbcr &" Nous sommes le "& Now & vbcr & string(40,"-") & vbcr & " Mon IP Publique est : "& Match.Value & vbcr & string(40,"*")
Next
Call OpenLog("monip.txt")
End Sub
Sub OpenLog(File)
Dim ws
Set ws = CreateObject("wscript.shell")
ws.run "Notepad " & File,1,True
Set ws = Nothing
End Sub
Sub ReNewLocalIP
Dim Ws,command,StrCommand,Resultat
Set Ws = CreateObject("WScript.Shell")
command = "ipconfig /release & ipconfig /flushdns & ipconfig /renew"
StrCommand = "cmd /k "& command &""
Resultat = ws.Run(StrCommand,1,True)
End Sub |