无忧启动论坛

标题: (已解决)pe下获取本机用户名与ip、dns地址 [打印本页]

作者: xiao75918    时间: 2010-4-27 10:18
标题: (已解决)pe下获取本机用户名与ip、dns地址
虽然手动可以获得,但如果有个工具会方便很多。

进PE,运行注册表编辑器regedit,加载配置单元:windows\system32\config\下的SYSTEM文件。

用户名
[HKEY_LOCAL_MACHINE\sys\SYSTEM\ControlSet001\Control\ComputerName\ComputerName]
"ComputerName"="******"

ip、dns地址:
[HKEY_LOCAL_MACHINE\sys\SYSTEM\ControlSet001\Services\Tcpip\Parameters\Interfaces]
这个下面有几个项,其中一个里面就有


感谢dos时代菜鸟提供批处理
默认操作系统目录为C:\windows,如在其它盘请直接找到windows\system32\config\下的SYSTEM文件拖放到下面批处理上即可。

@echo off
set tempsys=%1
if %1*==* SET TEMPSYS=C:\windows\system32\config\SYSTEM
REG LOAD HKLM\TEMPSYS %tempsys%
set regx=HKLM\TEMPSYS\ControlSet001
echo 显示本地网标 >%temp%\temp.txt
for /f "tokens=3" %%c in ('reg query %regx%\Control\ComputerName\ComputerName ^| find /i "computername"') do echo %%c >>%temp%\temp.txt
echo.>>%temp%\temp.txt
echo 显示本地固定ip>>%temp%\temp.txt
for /f %%c in ('reg query %regx%\Services\Tcpip\Parameters\Interfaces') do (
   for /f "tokens=3" %%d in ('reg query %%c /v ipaddress^|find /i "ipaddress"') do if not %%d*==0.0.0.0\0\0*  echo %%d>>%temp%\temp.txt
  )
echo.>>%temp%\temp.txt
echo 显示本地子网掩码>>%temp%\temp.txt
for /f %%c in ('reg query %regx%\Services\Tcpip\Parameters\Interfaces') do (
   for /f "tokens=3" %%d in ('reg query %%c /v subnetmask^|find /i "subnetmask"') do if not %%d*==0.0.0.0\0\0*  echo %%d>>%temp%\temp.txt
  )
echo.>>%temp%\temp.txt
echo 显示本地默认网关>>%temp%\temp.txt
for /f %%c in ('reg query %regx%\Services\Tcpip\Parameters\Interfaces') do (
   for /f "tokens=3" %%d in ('reg query %%c /v defaultgateway^|find /i "defaultgateway"') do if not %%d*==\0* echo %%d>>%temp%\temp.txt
  )
echo 显示本地固定dns>>%temp%\temp.txt
for /f %%c in ('reg query %regx%\Services\Tcpip\Parameters\Interfaces') do (
   for /f "tokens=3" %%d in ('reg query %%c /v nameserver^|find /i "nameserver"') do echo %%d>>%temp%\temp.txt
  )
echo.>>%temp%\temp.txt
REG UNLOAD HKLM\TEMPSYS
cls
type %temp%\temp.txt
echo.
pause

[ 本帖最后由 xiao75918 于 2010-4-29 14:36 编辑 ]
作者: kloikjj    时间: 2010-4-27 17:30
能这样获取也好呀,如果有工具则更好,顶一下
作者: slore    时间: 2010-4-27 19:39
reg 命令可以挂在注册表文件。。。所以P处理可以写出来的
作者: yanglin    时间: 2010-4-28 08:51
ip、dns地址:
[HKEY_LOCAL_MACHINE\sys\SYSTEM\ControlSet001\Services\Tcpip\Parameters\Interfaces]
这个下面有几个项,其中一个里面就



ControlSet001 你这个键值是不一定的 有的时候是 无线网卡的位置或是其他的
所以
建议使用 ipconfig /all 命令老做比较好些
作者: xianglang    时间: 2010-4-28 11:40
一般PE都不带ipconfig的。
作者: xiao75918    时间: 2010-4-29 08:43
ipconfig/all只能反映当前系统的ip地址,而不能反映离线系统的ip,有时给一些内网用户维护安装系统,当前系统进不去了,而他不记得ip,很麻烦。所以发贴希望在pe下读取系统注册表文件来获得ip地址。
作者: nsdiy    时间: 2010-4-29 10:09
我记得好像有一个命令可以显示离线系统的IP
作者: yang162    时间: 2010-4-29 11:46
这个严重支持了 期待 ....
作者: dos时代菜鸟    时间: 2010-4-29 12:38
得到本地 网标/ip/dns 的方法。大家测试一下。
把信息源文件托放到这个cmd批处理中就可以了。不托放默认信息源 :c:\WINDOWS\SYSTEM32\SYSTEM

@echo off
set tempsys=%1
if %1*==* SET TEMPSYS=
C:\windows\system32\config\SYSTEM
REG LOAD HKLM\TEMPSYS %tempsys%
set regx=HKLM\TEMPSYS\ControlSet001
echo 显示本地网标 >%temp%\temp.txt
for /f "tokens=3" %%c in ('reg query %regx%\Control\ComputerName\ComputerName ^| find /i "computername"') do echo %%c >>%temp%\temp.txt


echo 显示本地固定ip>>%temp%\temp.txt
for /f %%c in ('reg query %regx%\Services\Tcpip\Parameters\Interfaces') do (
   for /f "tokens=3" %%d in ('reg query %%c /v ipaddress^|find /i "ipaddress"') do echo %%d>>%temp%\temp.txt
  )

echo 显示本地固定dns>>%temp%\temp.txt
for /f %%c in ('reg query %regx%\Services\Tcpip\Parameters\Interfaces') do (
   for /f "tokens=3" %%d in ('reg query %%c /v nameserver^|find /i "nameserver"') do echo %%d>>%temp%\temp.txt
  )
cls

REG UNLOAD HKLM\TEMPSYS
type %temp%\temp.txt
pause


[ 本帖最后由 dos时代菜鸟 于 2010-4-29 13:10 编辑 ]
作者: xiao75918    时间: 2010-4-29 13:19
如果能加一个自动搜索c、d、e盘windows\system32\config\SYSTEM文件就全自动了。

还请加一个网关吧

[ 本帖最后由 xiao75918 于 2010-4-29 13:21 编辑 ]
作者: dos时代菜鸟    时间: 2010-4-29 13:29
原帖由 xiao75918 于 2010-4-29 13:19 发表
如果能加一个自动搜索c、d、e盘windows\system32\config\SYSTEM文件就全自动了。

还请加一个网关吧


1、自动搜索? 也很简单,但是个人认为还是托放比较安全通用,你可以通过“搜索”功能找出全部system 然后在搜索结果窗口依次托放。
2、增加默认网关?你就不能自己动手添加下么? 就多一个 defaultwaygate
这是增加 网关的,要在增加别的,你自己diy吧。

@echo off
set tempsys=%1
if %1*==* SET TEMPSYS=C:\windows\system32\config\SYSTEM

REG LOAD HKLM\TEMPSYS %tempsys%
set regx=HKLM\TEMPSYS\ControlSet001

echo 显示本地网标 >%temp%\temp.txt
for /f "tokens=3" %%c in ('reg query %regx%\Control\ComputerName\ComputerName ^| find /i "computername"') do echo %%c >>%temp%\temp.txt
echo.>>%temp%\temp.txt
echo 显示本地固定ip>>%temp%\temp.txt
for /f %%c in ('reg query %regx%\Services\Tcpip\Parameters\Interfaces') do (
   for /f "tokens=3" %%d in ('reg query %%c /v ipaddress^|find /i "ipaddress"') do if not %%d*==0.0.0.0\0\0*  echo %%d>>%temp%\temp.txt
  )
echo.>>%temp%\temp.txt
echo 显示本地固定dns>>%temp%\temp.txt
for /f %%c in ('reg query %regx%\Services\Tcpip\Parameters\Interfaces') do (
   for /f "tokens=3" %%d in ('reg query %%c /v nameserver^|find /i "nameserver"') do echo %%d>>%temp%\temp.txt
  )
echo.>>%temp%\temp.txt
echo 显示本地默认网关>>%temp%\temp.txt
for /f %%c in ('reg query %regx%\Services\Tcpip\Parameters\Interfaces') do (
   for /f "tokens=3" %%d in ('reg query %%c /v defaultgateway^|find /i "defaultgateway"') do if not %%d*==\0* echo %%d>>%temp%\temp.txt
  )

REG UNLOAD HKLM\TEMPSYS
cls
type %temp%\temp.txt
echo.
pause


[ 本帖最后由 dos时代菜鸟 于 2010-4-29 13:37 编辑 ]
作者: xiao75918    时间: 2010-4-29 14:09
非常感谢ls




欢迎光临 无忧启动论坛 (http://bbs.wuyou.net/) Powered by Discuz! X3.3