@echo off
setlocal enabledelayedexpansion
chcp 65001 >nul
title Veyon Scan and Add Hosts
set "name=Cabinet"
set "cli=%PROGRAMFILES%\Veyon\veyon-cli.exe"
set "NET=192.168.0"
set "START=1"
set "END=254"
set "PORT=11100"
set "PREFIX=PC"
set "MYIPS= "
for /f %%a in ('powershell -NoProfile -Command "(Get-NetIPAddress -AddressFamily IPv4).IPAddress"') do set "MYIPS=!MYIPS!%%a "
echo Мои адреса: !MYIPS!
"%cli%" networkobjects add location "%name%"
for /L %%i in (%START%,1,%END%) do (
set "SKIP=0"
if not "!MYIPS: %NET%.%%i =!"=="!MYIPS!" set "SKIP=1"
if "!SKIP!"=="1" (
echo %NET%.%%i - это я, пропускаю
) else (
powershell -NoProfile -Command "$c=New-Object Net.Sockets.TcpClient; try {$a=$c.BeginConnect('%NET%.%%i',%PORT%,$null,$null); if($a.AsyncWaitHandle.WaitOne(200,$false) -and $c.Connected) {exit 0} else {exit 1}} catch {exit 1} finally {$c.Close()}"
if not errorlevel 1 (
echo %NET%.%%i OPEN - adding to Veyon...
"%cli%" networkobjects add computer "%PREFIX%-%%i" "%NET%.%%i" "" "%name%"
)
)
)
pause
*текст* - жирный,
~текст~ - курсивный,
-текст- - _текст_ - подчеркнутый