:获取DHCP服务器IP
wntipcfg /all /batch %temp%\ipconfig.txt
for /f "usebackq tokens=2 delims=:" %%i in (`find /i "DHCP Server" %TEMP%\ipconfig.txt`) do set PXE_SERVER=%%i
set PXE_SERVER=%PXE_SERVER:~1%
goto :EOF
:映射网络磁盘
setlocal
if exist %WinDir%\SERV_SET.bat call %WinDir%\SERV_SET.bat
if not defined PXE_SERVER call :获取DHCP服务器IP
if not defined SHARE_NAME set SHARE_NAME=pe$
if not defined SHARE_USER set SHARE_USER=Guest
if not defined SHARE_PASS set SHARE_PASS=""
::等待网络运行正常.
echo.%time% 等待网络连接并映射网络共享\\%PXE_SERVER%\%SHARE_NAME%为Y:......
:等待
if "%n%"=="10" goto :服务器不通
ping /n 1 /w 1000 %PXE_SERVER% >nul&& goto :map
set/an+=1 >nul
goto :等待
:map
net use Y: \\%PXE_SERVER%\%SHARE_NAME% %SHARE_PASS% /user:%SHARE_USER% >NUL 2>NUL || net use Y: \\%PXE_SERVER%\%SHARE_NAME% %SHARE_PASS% /user:%SHARE_USER%@%COMPUTERNAME% >NUL 2>NUL|| (pause>nul|ECHO.%TIME% 网络映射失败: net use Y: \\%PXE_SERVER%\%SHARE_NAME% %SHARE_PASS% /user:%SHARE_USER%)
pecmd wait 2000