I am attempting to write a script that will check to see if a computer is on my LAN before running the rest of my script. It is a simple backup script using robocopy
Thanks to you both. I tried both but in the end this is what worked for me
set machine=userbox
ping -n 1 %machine% | find "TTL=" >nul
IF errorlevel 1 (
echo "Computer Not On" %date% %time% > c:\scripts\%machine%-computeroff.log
) ELSE (
robocopy source destination
shutdown.exe /s /m \\%machine% /c "Mandatory Shutdown in progress. You have 10 minutes" /t 600
echo "shutdown command given" %date% %time% > c:\scripts\shutdown-%machine%.log
Cheers