|
我看win7pe确实没那么简单,有些程序因为IPV6的关系而出错,请大家仔细对照一下,如ipconfig,好多TFTP的批处理中是从第3个:号读IP,由于IPv6的参与可能要4行;ping /n1 %computer%,得到的是ipv6的回应,要ipv4必须加-4参数。
请各位对照一下,要作代码的改动。以下是改好的tftpd.cmd的代码,支持在PE中或正常系统中、支持在光盘或ISO解开后的任意目录中执行、支持查找启动文件和外置目录盘。(注意,此程序位于h3pe下的一个目录中,带参数执行被认为是在PE中。请根据实情修改)- @echo off
- PUSHD %~dp0
- set TP=%cd%
- cd ..\..
- set TFTPROOT=%cd%
- set PR=%TFTPROOT%
- cd %tp%
- SET LAST=%PR:~-1%
- IF "%LAST%"=="" set PR=%PR:~0,-1%
- IF NOT "%IniDrv%"=="" SET PR=%IniDrv%
- IF "%BootOS%"=="" ver|find /i " 5.2">nul &&SET BootOS=03
- IF "%BootOS%"=="" ver|find /i " 6.1">nul &&SET BootOS=W7
- :DHCP
- rem 定义启动引导文件
- IF "%1"=="" (
- CLS
- SET Choice=
- Echo.
- Echo 〖请问〗
- Echo.
- SET /P Choice=工作站要使用Grub方式启动吗?(Y/直接回车或其他键代表按默认的LINUX方式启动):
- ECHO.
- IF NOT "%Choice%"=="" SET Choice=%Choice:~0,1%
- IF /I "%Choice%"=="y" SET PXEFN=grldr
- ) ELSE (
- if "%PXEFN%"=="" PECMD.EXE LOAD %1\PXEFILE.INI
- if "%PXEFN%"=="" For /F "tokens=3" %%i In ('REG QUERY "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /V PXEFN^|find /I "PXEFN"') do SET PXEFN=%%i
- )
- IF "%PXEFN%"=="" SET PXEFN=pxelinux.0
- IF EXIST %PR%\%PXEFN% goto FindBootFile
- for %%i in (z y x w v u t s r q p o n m l k j i h g f e d c b a) do if exist %%i:\%PXEFN% set TFTPROOT=%%i:\&&goto FindBootFile
- IF EXIST %Windir\System32\pecmd.exe (
- PECMD.EXE MESS 找不到启动文件:%PR%\%PXEFN%,准备好启动文件后请继续……@提示:缺少网启文件 #OK
- ) ELSE echo 找不到启动文件:%PR%\%PXEFN%,准备好启动文件后请继续…… &&pause
- GOTO DHCP
- :FindBootFile
- COPY TFTPD*.*.* %temp% /y >nul
- SET TP=%temp%
- PECMD FIND DHCP4NT.EXE,KILL DHCP4NT.EXE >nul 2>nul
- set/a a=-2
- IF "%BootOS%"=="W7" set/a a=-3
- for /f "usebackq tokens=2 delims=:" %%i in (`ipconfig`) do (
- set b=%%i
- call :getip
- )
- For /F "tokens=3" %%i In ('REG QUERY "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName" /V ComputerName') do SET ComputerName=%%i
- for /f "tokens=1-3,4 delims=." %%i in ("%_myip%") do set/a IP_Pool=100*256*256*256+%%k*256*256+%%j*256+%%i
- for /f "tokens=1-3,4 delims=." %%i in ("%_mask%") do set/a mask=%%l*256*256*256+%%k*256*256+%%j*256+%%i
- for /f "tokens=1-3,4 delims=." %%i in ("%_Gateway%") do set/a Gateway=%%l*256*256*256+%%k*256*256+%%j*256+%%i
- >%TP%\TFTPD32.INI echo.[TFTPD32]
- >>%TP%\TFTPD32.INI echo.
- >>%TP%\TFTPD32.INI echo.Console Password=tftpd32
- >>%TP%\TFTPD32.INI echo.TftpPort=69
- >>%TP%\TFTPD32.INI echo.Negociate=1
- >>%TP%\TFTPD32.INI echo.ShowProgressBar=1
- >>%TP%\TFTPD32.INI echo.Timeout=3
- >>%TP%\TFTPD32.INI echo.MaxRetransmit=6
- >>%TP%\TFTPD32.INI echo.SecurityLevel=1
- >>%TP%\TFTPD32.INI echo.UnixStrings=1
- >>%TP%\TFTPD32.INI echo.Services=47
- >>%TP%\TFTPD32.INI echo.PersistantLeases=1
- >>%TP%\TFTPD32.INI echo.DHCP Ping=1
- >>%TP%\TFTPD32.INI echo.Max Simultaneous Transfers=100
- >>%TP%\TFTPD32.INI echo.TFTPROOT=%TFTPROOT%
- >>%TP%\TFTPD32.INI echo.[DHCP]
- >>%TP%\TFTPD32.INI echo.IP_Pool=%IP_Pool%
- >>%TP%\TFTPD32.INI echo.PoolSize=100
- >>%TP%\TFTPD32.INI echo.Gateway=%Gateway%
- >>%TP%\TFTPD32.INI echo.Mask=%mask%
- rem >>%TP%\TFTPD32.INI echo.DNS=%Gateway%
- >>%TP%\TFTPD32.INI echo.BootFile=%PXEFN%
- rem 对H3PE所在的盘共享为PEROOT
- set ExtDrv=%IniDrv%\
- IF NOT Exist %ExtDrv%\H3PE\WINPE.INI for %%i in (z y x w v u t s r q p o n m l k j i h g f e d c b a) do IF exist %%i:\H3PE\WINPE.INI set ExtDrv=%%i:\
- IF NOT Exist %ExtDrv%\H3PE\WINPE.INI set ExtDrv=%TFTPROOT%
- net share PEROOT /d >nul 2>nul
- net share PEROOT=%ExtDrv% /grant:Guest,full /unlimited
- rem icacls %ExtDrv% /t /grant everyone:f
- echo.
- echo 已将本机 %TFTPROOT% 共享给远程客户(资源名:\\%COMPUTERNAME%\PEROOT,用户名:Guest,密码为空)
- echo.
- IF EXIST %Windir\System32\pecmd.exe (
- PECMD.EXE LINK !%%DESKTOP%%\TFTPD32网络启动服务端,%TP%\TFTPD32.EXE
- PECMD.EXE LINK !%%Programs%%\网络启动服务器\TFTPD32网络启动服务端,%TP%\TFTPD32.EXE
- PECMD.EXE FILE "%%DESKTOP%%\开启HaneWin网络启动服务端.*"
- PECMD.EXE FILE "%%DESKTOP%%\开启TFTPD32网络启动服务端.*"
- )
- start %TP%\TFTPD32.EXE
- :END
- EXIT
- :::::::::子程序区::::::::::::::
- :getip
- set /a a=%a%+1
- if %a%==1 set _myip=%b%
- if %a%==2 set _mask=%b%
- if %a%==3 set _Gateway=%b%
- goto :eof
复制代码
[ 本帖最后由 hhh333 于 2010-11-27 21:56 编辑 ] |
|