![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-05 10:23 |
48,038 topics / 350,123 posts / today 1 new / 48,251 members |
| DOS批处理 & 脚本技术(批处理室) » How do I modify a batch file to use an IP to look up the machine name? |
| Printable Version 745 / 1 |
| Floor1 lygwdyanzi | Posted 2007-07-07 16:08 |
| 初级用户 Posts 26 Credits 51 | |
|
I want to use the batch file below to enter an IP address and get the machine name. The code is as follows, but it doesn't give the expected result.
@echo off set b= set/p b=Please enter the IP address: for /f "skip=8 tokens=1 delims= " %%i in ('nbtstat -a %b%') do echo The machine name for %b% is: %%i pause>nul When I enter 192.168.0.1, I get: Please enter the IP address:192.168.0.1 The machine name for 192.168.0.1 is: PC6 The machine name for 192.168.0.1 is: PC6 The machine name for 192.168.0.1 is: WORKGROUP The machine name for 192.168.0.1 is: WORKGROUP The machine name for 92.168.0.1 is: The machine name for 192.168.0.1 is: MAC The machine name for 92.168.0.1 is: The machine name for 192.168.0.1 is: 11: The machine name for 192.168.0.1 is: Node The machine name for 92.168.0.1 is: The machine name for 192.168.0.1 is: Host How can I make it return only the machine name? If I want to add a line like: The workgroup the machine belongs to is: then how do I do it? Thanks. |
|
| Floor2 ncqingyi | Posted 2007-07-13 11:57 |
| 初级用户 Posts 11 Credits 24 | |
|
@echo off
set b= set/p b=Please enter the IP address: for /f "tokens=1 delims= " %%i in ('nbtstat -a %b%^|find "<20>"') do echo The machine name for %b% is: %%i set This should be your program with a small modification. |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |