|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Member
Iscritto dal: Oct 2008
Messaggi: 39
|
[BATCH / VBSCRIPT / JScript] Ping e spegnegnere il pc
Mi serve uno script fatto in un qualunque linguaggio che esegua un ping ad un indirizzo. Se il pc risponde non fa nulla, altrimenti spegne un certo computer col comando "shutdown -s -f -t 0 -m \\DC1"
Non riesco a gestire questa storia del ping... Qualcuno mi aiuta? BATCH: Codice:
ping -n 1 192.168.1.3 | find "durata" > nul if errorlevel 1 echo %errorlevel% && shutdown -s -t 60 -f Codice:
Dim i
i=2
ECHstrMachines = "PC-Inesistente;192.168.1.110"
aMachines = split(strMachines, ";")
For Each machine in aMachines
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
ExecQuery("select * from Win32_PingStatus where address = '"_
& machine & "'")
For Each objStatus in objPing
If IsNull(objStatus.StatusCode) or objStatus.StatusCode<>0 Then
WScript.Echo("Computer " & machine & " is not reachable")
i=i-1
End If
Next
Next
WScript.Echo i
If i <= 0 Then
Dim objShell
Dim strShutdown
strShutdown = "shutdown -s -t 60 -f"
set objShell = CreateObject("WScript.Shell")
objShell.Run strShutdown
End If
Wscript.Quit
__________________
Mala Rupta! |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 12:33.



















