China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-24 17:59
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Original] Fully Automatic Tool for Setting Machine Numbers and IP (Absolutely Practical) View 24,721 Replies 148
Floor 91 Posted 2007-06-23 21:12 ·  中国 宁夏 银川 西夏区 电信
新手上路
Credits 2
Posts 1
Joined 2007-06-23 20:43
19-year member
UID 92185
Gender Male
Status Offline
Thanks a lot. Just what I needed.
Floor 92 Posted 2007-07-02 04:30 ·  中国 广西 钦州 灵山县 电信
初级用户
Credits 75
Posts 36
Joined 2007-05-11 10:12
19-year member
UID 88144
Gender Male
Status Offline
Good things are shared by everyone, and everyone studies them!
Floor 93 Posted 2007-07-05 02:56 ·  中国 山东 青岛 电信
新手上路
Credits 2
Posts 1
Joined 2007-07-05 02:34
18-year member
UID 93173
Gender Male
Status Offline
Floor 94 Posted 2007-07-05 11:09 ·  中国 辽宁 锦州 联通
新手上路
Credits 10
Posts 5
Joined 2007-06-27 13:27
18-year member
UID 92480
Gender Male
Status Offline
Ask the LZ and all the experts:

In the LZ's code:

for /f "tokens=12 delims= " %%i in ('ipconfig /all^|find /i "Physical Address"') do (
set mac=%%i
set mac=!mac:~0,-1!
)

What does!mac:~0,-1! mean?

I learned batch processing a long time ago, but very superficially. I checked some materials, and in the article by moderator lxmxn, it is mentioned:
! !
① When variable delay is enabled, using!! to enclose the variable name means to reference the variable value.
But I still can't infer the function of!mac:~0,-1!.

Please be generous to give your advice! Thanks a lot!
Floor 95 Posted 2007-07-07 01:38 ·  中国 广东 湛江 廉江市 电信
高级用户
★★★
Credits 959
Posts 311
Joined 2006-04-11 14:08
20-year member
UID 53665
Gender Male
From 广东-LianJiang
Status Offline


!mac:~0,-1!


Extract all characters of the mac variable except the last one.

You can use
set /?

to take a look.


[ Last edited by qasa on 2007-7-7 at 01:40 AM ]
κχυμγνξοθπρωψιαδλεηφβτζσ┬╀┾┳┞┯┰┱┣┲┳╂╁│├┟┭┠这是什么??这就是我的人生
Floor 96 Posted 2007-07-08 21:09 ·  中国 上海 虹口区 电信
新手上路
Credits 2
Posts 1
Joined 2007-07-08 20:42
18-year member
UID 93485
Gender Male
Status Offline
Support
Floor 97 Posted 2007-07-12 22:40 ·  中国 广东 深圳 宝安区 电信
中级用户
★★
Credits 253
Posts 112
Joined 2005-12-20 00:31
20-year member
UID 47500
Status Offline
Floor 98 Posted 2007-07-13 06:18 ·  中国 北京 北京华宇兴盛科技发展有限公司电信节点
初级用户
Credits 34
Posts 15
Joined 2007-05-01 22:15
19-year member
UID 87228
Gender Male
Status Offline
????:lol::lol::lol:

[ Last edited by oioc on 2007-7-16 at 06:22 AM ]
Floor 99 Posted 2007-07-13 07:34 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 452
Posts 202
Joined 2006-12-21 13:46
19-year member
UID 74161
Gender Female
Status Offline
Actually, I already knew about this tool a long time ago, but I haven't used it. Now the internet café is about to change the system, so it's just right to test it. However, before that, I hope you can improve its fully automatic function!

Can the data format in your MAC file be changed to be like the format scanned out in the A-D tool kit? That way, there's no need to change the format one by one, or you can directly write a batch script to scan MAC, IP, and computer name.

Actually, I can also do it, but it will take time. I'm not as skilled as you, so if you don't want to do it, I'll spend some time making it and integrate it with your tool to truly achieve full automation!!!
Floor 100 Posted 2007-07-13 08:40 ·  中国 江苏 常州 电信
初级用户
Credits 65
Posts 30
Joined 2005-11-11 10:42
20-year member
UID 45039
Status Offline
Not bad. I was just thinking about writing one during the holiday. For computer lab management.
Floor 101 Posted 2007-07-13 11:10 ·  中国 广东 佛山 电信
初级用户
★★
Credits 193
Posts 98
Joined 2007-01-17 11:56
19-year member
UID 76803
Gender Male
Status Offline
...Learned it...
这家伙很聪明 什么都没留下
Floor 102 Posted 2007-07-13 12:19 ·  中国 江苏 苏州 电信
初级用户
Credits 24
Posts 11
Joined 2007-07-13 10:36
18-year member
UID 93864
Gender Male
Status Offline
setlocal enabledelayedexpansion
This command is of utmost importance.

Additionally, to change the computer name, you can use the WMIC method.
Black/White
Mono
CGA
VGA
SVGA
LCD
十年工龄 For disk operation system
Floor 103 Posted 2007-07-13 12:25 ·  中国 江苏 苏州 电信
初级用户
Credits 24
Posts 11
Joined 2007-07-13 10:36
18-year member
UID 93864
Gender Male
Status Offline
Originally posted by 5639863 at 2007-6-18 11:29 AM:
Well, it's really powerful, but now I find that most of these tools can not modify connections like Local Area Connection 2 or Local Area Connection 3! But this tool has greatly facilitated network administrators


Configure or update IP address:
wmic nicconfig where index=0 call enablestatic("192.168.1.5"), ("255.255.255.0")

; index=0 means to configure network interface 1. index=1 means to modify the second one.

Configure gateway (default route):
wmic nicconfig where index=0 call setgateways("192.168.1.1"),(1)

The following is the list of my two network cards, only the first one is, the others are not.

Broadcom NetXtreme 57xx
RAS Synchronous Adapter
Packet Scheduler Miniport
WAN Miniport (L2TP)
WAN Miniport (PPTP)
WAN Miniport (PPPOE)
Direct Parallel
WAN Miniport (IP)
Packet Scheduler Miniport
WAN Miniport (IPX)

Then use WMIC to do Output to achieve self-judgment.
Black/White
Mono
CGA
VGA
SVGA
LCD
十年工龄 For disk operation system
Floor 104 Posted 2007-07-13 14:19 ·  中国 广东 广州 白云区 电信
新手上路
Credits 2
Posts 1
Joined 2006-10-11 23:53
19-year member
UID 65369
Status Offline
Floor 105 Posted 2007-07-26 15:55 ·  中国 广东 湛江 廉江市 电信
高级用户
★★★
Credits 959
Posts 311
Joined 2006-04-11 14:08
20-year member
UID 53665
Gender Male
From 广东-LianJiang
Status Offline
Reply to post 97 and post 104, such problems have long been solved, and it's actually very simple. Whether you are Local Area Connection 1, Local Area Connection 2, Local Area Connection 3...... it's all okay. Now attach the code for everyone to see.
......
for /f "tokens=1 delims=" %%s in ('ipconfig /all^|find /i "Ethernet adapter"') do (set ss_=%%s)
set ss_=%ss_:~17,-2%
netsh interface IP Set Address "%ss_%" Static %2 %zwym_% %workgate_% 1 >nul
......

κχυμγνξοθπρωψιαδλεηφβτζσ┬╀┾┳┞┯┰┱┣┲┳╂╁│├┟┭┠这是什么??这就是我的人生
Forum Jump: