[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[文本处理] 【已解决】xp系统下,受限用户如何用批处理在不使用wmic获取多个网卡的IP地址?

本帖最后由 zds612 于 2016-7-14 14:43 编辑

各位大大,最近给公司车间的电脑做一个开机自检批处理,windows xp环境

需要上报本机的IP地址、计算机名(以便定位该主机位置),计算机名当然是很简单,就是多网卡多IP把我难住了,论坛及网上找了资料也没能解决

因为电脑是连接机床的,大部分网卡大于1,甚至一台电脑三个网卡

为了准确获得我需要的IP,我希望将该电脑的所有网卡IP地址,都获取出来

现有一个代码:
  1. @echo off
  2. wmic nicconfig get IPAddress /value | findstr /i "IPAddress=[^]"
  3. pause
复制代码
但因为是车间电脑,用户只有power user权限,没有administrator,所以上面的方法不能使用

特来论坛求助各位大侠,有没有别的方法可以获取到本机所有的IP地址

最好是不调用其他组件,而是通过文本处理得到

当然,调用其他组件的方法也恳请提供,我测试一下

非常感谢!

最后附上我的小白代码,见笑了
  1. @echo off
  2. :start
  3. net user %username%|find "Administrators">nul&&(goto shangbao)||((echo administrator is Disabled.)&&(goto check_net))
  4. :shangbao
  5. echo =================================================================>>\\132.147.176.50\可写\mis_super.txt
  6. echo 当前时间:%date:~6,2%年%date:~3,2%月%date:~0,2%日%time:~0,8%>>\\132.147.176.50\可写\mis_super.txt
  7. echo 我的计算机名是:%computername%>>\\132.147.176.50\可写\mis_super.txt
  8. wmic nicconfig get IPAddress /value | findstr /i "IPAddress=[^]">>\\132.147.176.50\可写\mis_super.txt
  9. echo 经检测,我拥有超级管理员权限,请处理!>>\\132.147.176.50\可写\mis_super.txt
  10. echo =================================================================>>\\132.147.176.50\可写\mis_super.txt
  11. echo.>>\\132.147.176.50\可写\mis_super.txt
  12. echo.>>\\132.147.176.50\可写\mis_super.txt
  13. echo 拥有超管,已上报!
  14. :check_net
  15. echo 开始检查ping 180.2...
  16. ping -n 3 132.147.180.2>nul && goto :net_ok || goto :net_notok
  17. :net_ok
  18. echo =================================================================>>\\132.147.176.50\可写\mis_home.txt
  19. echo 当前时间:%date:~6,2%年%date:~3,2%月%date:~0,2%日%time:~0,8%>>\\132.147.176.50\可写\mis_home.txt
  20. echo 我的计算机名是:%computername%>>\\132.147.176.50\可写\mis_home.txt
  21. wmic nicconfig get IPAddress /value | findstr /i "IPAddress=[^]">>\\132.147.176.50\可写\mis_home.txt
  22. echo -----------------------ipconfig start----------------------->>\\132.147.176.50\可写\mis_home.txt
  23. ipconfig>>\\132.147.176.50\可写\mis_home.txt
  24. echo ------------------------ipconfig end------------------------>>\\132.147.176.50\可写\mis_home.txt
  25. echo 经检测,我可以ping通180.2,请处理!>>\\132.147.176.50\可写\mis_home.txt
  26. echo =================================================================>>\\132.147.176.50\可写\mis_home.txt
  27. echo.>>\\132.147.176.50\可写\mis_home.txt
  28. echo.>>\\132.147.176.50\可写\mis_home.txt
  29. echo 连接180.2成功,已上报!
  30. pause
  31. goto start
  32. :net_notok
  33. echo 无法连接180.2,正常。
  34. pause
  35. exit
复制代码

如果 ipconfig /all可以列出来所有网卡信息。那就用这个来取。
去学去写去用才有进步。安装python3代码存为xx.py 双击运行或右键用IDLE打开按F5运行

TOP

把 ipconfig /all 的结果发出来看看
Talk is cheap. Show me the code.
没事不要瞎扯淡,有能耐就把代码贴出来给我看。

TOP

本帖最后由 zds612 于 2016-7-14 08:32 编辑

回复 3# gawk


Windows IP Configuration
Ethernet adapter 本地连接:
        Connection-specific DNS Suffix  . :
        IP Address. . . . . . . . . . . . : 132.147.176.75
        Subnet Mask . . . . . . . . . . . : 255.255.255.0
        Default Gateway . . . . . . . . . : 132.147.176.254
Ethernet adapter 本地连接 3:
        Connection-specific DNS Suffix  . :
        IP Address. . . . . . . . . . . . : 132.147.176.98
        Subnet Mask . . . . . . . . . . . : 255.255.255.0
        Default Gateway . . . . . . . . . :
Ethernet adapter 本地连接 2:
        Connection-specific DNS Suffix  . :
        IP Address. . . . . . . . . . . . : 132.147.176.86
        Subnet Mask . . . . . . . . . . . : 255.255.255.0
        Default Gateway . . . . . . . . . : 132.147.176.254

粘贴到这多了好多回车,我给去掉了。。

TOP

  1. ipconfig /all | findstr /c:"IP Address"
复制代码

TOP

回复 5# GNU


    谢谢大侠!非常感谢!

TOP

返回列表