检测域是否可用

检测域是否可用,并向指定文件写入值

1
2
3
4
5
6
7
8
9
10
11
12
@echo off

set domainController=DESKTOP-MQ0RV6A
set resultFile=domain_status.txt

:checkDomain
ping %domainController% -n 1 >nul
if errorlevel 1 (
echo 0 > %resultFile%
) else (
echo 1 > %resultFile%
)

向 domain_status.txt 写入多行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
@echo off

set domainController=DESKTOP-MQ0RV6A
set resultFile=domain_status.txt

:checkDomain
ping %domainController% -n 1 >nul
if errorlevel 1 (
(
echo Line 1: Domain %domainController% is not available.
echo Line 2: Additional information if needed.
echo Line 3: More information.
) > %resultFile%
) else (
(
echo Line 1: Domain %domainController% is available.
echo Line 2: Additional information if needed.
echo Line 3: More information.
) > %resultFile%
)

-------------本文结束感谢您的阅读-------------