test de connexion et reboot
Bonjour a tous.
je suis un novice en dévellopement et j'ai un soucis.
Je cherche a faire un VBS qui me permettrait de ping www.google.fr et si le test echoue. je souhaiterai que celui-ci se connecte en auto a mon routeur pour faire un redémarrage de celui-ci.
J'aurais besoin d'un coup de pouce.
Voila ou j'en suis :
Code:
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
| Dim shell, args, params, fso, fa,fs
Set shell = WScript.CreateObject("WScript.Shell")
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
Set args = Wscript.Arguments
Script=Lcase(Wscript.ScriptFullName)
set fs=fso.GetFile(Script)
sps=lcase(fs.ShortPath)
if ping = 0 then
shell.Run "telnet 192.168.0.1"
wscript.sleep 500
Shell.SendKeys "admin" & chr(13)
WScript.Sleep 500
Shell.SendKeys "passwd:" & chr(13)
WScript.Sleep 500
Shell.SendKeys "reboot" & chr(13)
WScript.Sleep 1
Shell.SendKeys "Logout" & chr(13)
WScript.Sleep 1
Shell.SendKeys "quit" & chr(13) & chr(13)
WScript.Sleep 1
Shell.SendKeys "exit" & chr(13)
else
Shell.SendKeys "exit" & chr(13)
end if
PING = Shell.Run("Ping.exe 192.168.0.1", 0,TRUE)
Msgbox "Resultat du PING " & PING
exit |
Ping Test Connexion Internet !
:salut: Voila un Script que j'utilise pour savoir si je suis vraiment connecté sur internet ou non :ccool: et c'est à vous de le modifier et de l'adapter pour votre script final ;)
Code:
1 2 3 4 5 6 7 8 9 10
| strComputer = "www.google.com"
msgbox "Ping de : " & strComputer,64,"Ping Test Connexion Internet"
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 PING OK . Vous êtes désormais connecté à INTERNET : " & objStatus.Statuscode,64,"Ping Test Connexion Internet"
else
msgbox "TEST PING ECHOUE . Vous n'êtes pas connecté à INTERNET: " & objStatus.Statuscode,16,"Ping Test Connexion Internet"
End If
Next |
et pour la partie de AutoLogin sur la page de votre routeur essaye de faire un copier / coller du code source HTML pour voir si vous pouvez le piloter automatiquement comme dans la :faq: Comment piloter Internet Explorer pour envoyer des informations à un site internet?