Advertisement
irelephant

Untitled

May 16th, 2024
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. @echo off
  2. setlocal
  3.  
  4. rem Input parameters
  5. set "ipAddress=%~1"
  6. set "message=%~2"
  7.  
  8. rem Function to check if a computer is online
  9. :TestComputerOnline
  10. ping -n 1 %ipAddress% >nul 2>&1
  11. if errorlevel 1 (
  12. echo %ipAddress% is not online
  13. exit /b 1
  14. ) else (
  15. exit /b 0
  16. )
  17.  
  18. rem Check if the target IP is online
  19. call :TestComputerOnline
  20. if errorlevel 1 (
  21. echo %ipAddress% is not online
  22. ) else (
  23. rem Send the message
  24. msg * /server:%ipAddress% %message%
  25. echo Message sent to %ipAddress%
  26. )
  27.  
  28. endlocal
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement