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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
| Call New_Local_IP
Call ActiverDHCP()
Call TestConnexionInternet()
Sub ActiverDHCP()
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableDHCP()
errGateways = objNetAdapter.SetGateways()
If errEnable = 0 Then
MsgBox "L'adresse IP a été bien changé et le DHCP est désormais Activé !" ,64, "Changer IP"
Else
MsgBox "L'adresse IP n'a pas été changé !" ,16, "Changer IP"
End If
Next
End Sub
Sub TestConnexionInternet() 'Pour Tester sa connexion Internet
Dim Boucle,strComputer,MsgTitre,objPing,objStatus
Boucle = True
While Boucle = True
strComputer = "smtp.gmail.com"
MsgTitre = "TEST DE CONNEXION INTERNET ET SMTP DE GMAIL © Hackoo © 2012"
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 ! ",64,MsgTitre
Boucle = False
Call Ip_Publique() ' Appel de la fonction 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 !",16,MsgTitre
End If
Next
wscript.sleep 60000
Wend
End Sub
Sub New_Local_IP 'Pour Renouveler l'adresse IP Locale
Dim Ws,command,StrCommand,Resultat
Set Ws = CreateObject("WScript.Shell")
command = "netsh interface ip delete arpcache & ipconfig /release & ipconfig /flushdns & ipconfig /renew & arp -a & nbtstat -R"
StrCommand = "cmd /c color 9B & mode con cols=65 lines=20 & "& command &""
Resultat = ws.Run(StrCommand,1,True)
End Sub
Sub Ip_Publique 'Pour sauvegarder un historique des adresses IP Publique qui ont été modifié dans un fichier texte
Dim Titre,URL,ie,objFSO,Data,OutPut,objRegex,Match,Matches
Titre = "Adresse Ip Publique © Hackoo © 2012"
URL = "http://monip.net"
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
Set OutPut = objfso.OpenTextFile("c:\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" ' Motif pour y extraire l'adresse IP Publique
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("c:\monip.txt")
End Sub
Sub OpenLog(File)
Dim ws
Set ws = CreateObject("wscript.shell")
ws.run "Notepad " & File,1,False
Set ws = Nothing
End Sub |
Partager