Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- setlocal
- rem Input parameters
- set "ipAddress=%~1"
- set "message=%~2"
- rem Function to check if a computer is online
- :TestComputerOnline
- ping -n 1 %ipAddress% >nul 2>&1
- if errorlevel 1 (
- echo %ipAddress% is not online
- exit /b 1
- ) else (
- exit /b 0
- )
- rem Check if the target IP is online
- call :TestComputerOnline
- if errorlevel 1 (
- echo %ipAddress% is not online
- ) else (
- rem Send the message
- msg * /server:%ipAddress% %message%
- echo Message sent to %ipAddress%
- )
- endlocal
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement