WinPE上网的方法
操作方法
- 01
WinPE上网的方法 发表时间: 2013-08-01来源:admin浏览:132次 如何实现WinPE上网功能呢,跟着来写一段WinPE上网的源码吧。 网启服务器自动配置程序:@echo offPUSHD %~dp0SET TP=%CD%Title HaneWin网启服务端通用免配程序for winPE_xp_03_win7rem ==========以下此行为启动引导文件,请自行修改,必须在分区根目录=======set bootfile=PXEgrldr.0rem ========================================================== echo正在自动搜索启动文件,可能需要一些时间,请稍等。。。set BaseDirectory=set bootdrver=%~d0for %%i in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if exist %%i:\%bootfile% set bootdrver=%%i:if not exist %bootdrver%\%bootfile% ECHO找不到网启文件:%bootfile% &&pause&& exitset BaseDirectory=%bootdrver%\rem if exist %bootdrver%\%bootfile% set BaseDirectory=%bootdrver%\&&goto copyfilerem for /f "usebackq" %%i in (`dir "%bootdrver%\%bootfile%" /s/b`) do set BaseDirectory=%%~dpirem if %BaseDirectory%.==. echo在%bootdrver%盘上找不到启动文件:%bootfile% &&pause :copyfilecopy DHCP*.* %temp% /y >nulset tp=%temp%%TP%\dhcp4nt.exe -remove >nulsetlocalset/a a=-2for /f "usebackq tokens=2 delims=:" %%i in (`ipconfig`) do (set b=%%icall :getip)for /f "tokens=1-3,4 delims=." %%i in ("%_myip%") do set IP_Pool=%%i.%%j.%%k.100>%TP%\DHCPsrv.ini echo.[License]>>%TP%\DHCPsrv.ini echo.Key=BBLZ26803UBBCAT9>>%TP%\DHCPsrv.ini echo.Name=Free User>>%TP%\DHCPsrv.ini echo.[DHCPsrv]>>%TP%\DHCPsrv.ini echo.Profile0=本地连接>>%TP%\DHCPsrv.ini echo.TFTPDirectory=%BaseDirectory%>>%TP%\DHCPsrv.ini echo.Multicast=0>>%TP%\DHCPsrv.ini echo.TFTPEnable=1>>%TP%\DHCPsrv.ini echo.TFTPPort=69>>%TP%\DHCPsrv.ini echo.TFTPMode=0>>%TP%\DHCPsrv.ini echo.Log=0>>%TP%\DHCPsrv.ini echo.TestIP=1>>%TP%\DHCPsrv.ini echo.ChangeIP=1>>%TP%\DHCPsrv.ini echo.EnableMAC=1rem有多个网卡时,如不能确定那个网卡,可以将下面此行去掉>>%TP%\DHCPsrv.ini echo.Include=%_myip%>>%TP%\DHCPsrv.ini echo.[本地连接]>>%TP%\DHCPsrv.ini echo.SubnetMask=%_mask%>>%TP%\DHCPsrv.ini echo.BaseIP=%IP_Pool%>>%TP%\DHCPsrv.ini echo.Range=101>>%TP%\DHCPsrv.ini echo.BootFile=%bootfile%>>%TP%\DHCPsrv.ini echo.GatewayIP=%_Gateway%大白菜官网>>%TP%\DHCPsrv.ini echo.InterfaceIP=%_myip%endlocal%tp%\dhcp4nt.exe -install >nulstart %tp%\dhcpsrv.cplif not exist x:\*.* goto windowsPECMD.EXE LINK %%Programs%%\网络工具\网启服务器\HaneWin网启服务端,%tp%\dhcpsrv.cpl,,%tp%\dhcp.icoPECMD.EXE LINK %%Programs%%\网络工具\网启服务器\开启HaneWin网启服务,%tp%\dhcp4nt.exe,-install,shell32.dll#96PECMD.EXE LINK %%Programs%%\网络工具\网启服务器\关闭HaneWin网启服务,%tp%\dhcp4nt.exe,-remove,shell32.dll#95PECMD FILE "%%DESKTOP%%\开启HaneWin网启服务端.*"rem删除共享名PEroot,建立共享名为PEROOT,共享资源为%BaseDirectory%PECMD EXEC CMD /C "net share PEROOT /d"PECMD EXEC CMD /C "net share PEROOT=%BaseDirectory% /unlimited"rem PECMD FIND EXPLORER.EXE,KILL EXPLORER.EXEecho.echo 已将本机PE系统[url=file://\\%Computername%\PEROOT]\\%Computername%\PEROOT[/url]共享给远程客户(主机名:%Computername%,用户名:Guest,密码为空):windowsecho.echo.echo 远程启动网启服务器.启动成功!可以进行远程网络启动PE!echo.pauseEXIT :getipset /a a=%a%+1if %a%==1 set _myip=%b%if %a%==2 set _mask=%b%if %a%==3 set _Gateway=%b%goto :eof ===================================================================================@ECHO OFFTitle HaneWin网启服务端_映射远程主机免配程序for winPEPUSHD %~dp0set tp=%cd%rem第一次运行pecmd.exe IFEX %%Desktop%%\映射远程主机.LNK,!EXEC cmd /c copy "%tp%\网启快捷及映射主机.CMD" "%tp%\映射远程主机.TMP"PECMD.exe LINK %%Desktop%%\映射远程主机,%tp%\网启快捷及映射主机.CMD,,SHELL32.DLL#17for %%i in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if exist %%i:\PETools\win7.ini PECMD.exe file %%Desktop%%\映射远程主机.*for %%i in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if exist %%i:\外置程序\winPE.ini PECMD.exe file %%Desktop%%\映射远程主机.*pecmd.exe IFEX %%Desktop%%\映射远程主机.LNK,!EXEC cmd /c copy "%tp%\网启快捷及映射主机.CMD" "%tp%\映射远程主机.TMP"if exist "%tp%\映射远程主机.TMP" goto endrem映射远程主机ipconfig /all |find /i "DHCP" |find /i "服务器">%temp%\ip.txtipconfig /all |find /i "DHCP" |find /i "Server">>%temp%\ip.txtfor /f "usebackq tokens=2 delims=:" %%i in (%temp%\ip.txt) do (set ip=%%i)set ip=%ip:~1%ECHO.ECHO将远程服务器%ip%的共享名peroot映射为本地Z:盘,主要是用于客户端,用户Guest,密码为空)ECHO .ECHO .ECHO正在连接至远程服务器:%ip%,请稍等。。。。。。ECHO.|NET USE z: [url=file://\\%ip%\PEROOT]\\%ip%\PEROOT[/url] /user:guest /persistent:nopecmd wait 200if exist z:\*.* PECMD.EXE MESS网络成功连接,并已连接远程服务器为Z:\n\n\n如不能连上InterNet网,请在网络设置中释放-更新络IP,或在服务器上关闭网络启动服端!@提示#ok *60000if exist z:\PETOOLS\Win7.INI PECMD.EXE LINK %%Desktop%%\加载远程外置程序1,PECMD.EXE,LOAD z:\PETOOLS\Win7.INI,Shell32.dll#46if exist z:\外置程序\winPE.ini PECMD.EXE LINK %%Desktop%%\加载远程外置程序2,PECMD.EXE,LOAD z:\外置程序\winPE.ini,Shell32.dll#46if not exist z:\*.* PECMD.EXE MESS无法连接远程服务器,请检查网络或服务器!!@提示#ok *60000:endpecmd.exe file "%tp%\映射远程主机.TMP"pecmd.exe file "%tp%\映射远程主机.TMP"pecmd.exe IFEX %%Desktop%%\映射远程主机.LNK,!LINK %%Programs%%\网络工具\网启服务器\HaneWin网启服务端,%tp%\HaneWin网启服务端.CMD,,%tp%\DHCP.ICOexit 这段源码可以根据自己的需要进行适当修改。到这里就可以实现WinPE上网的功能了。然后又将如何WinPE系统设定呢在linux下使用U盘的方法