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 13:16
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Original] Fully Automatic Tool for Setting Machine Numbers and IP (Absolutely Practical) View 24,707 Replies 148
Original Poster Posted 2007-01-19 17:40 ·  中国 广东 湛江 电信
高级用户
★★★
Credits 959
Posts 311
Joined 2006-04-11 14:08
20-year member
UID 53665
Gender Male
From 广东-LianJiang
Status Offline
### Fully Automatic Machine Number and IP Setting Tool
Haha, after half a month of study, my first big work is finally completed!!!
Put it up to share with colleagues in the internet café industry. If everyone thinks it's useful, give the little brother some points as an encouragement, hehehe :D

For more complete functions, please see:

http://www.cn-dos.net/forum/viewthread.php?tid=26870&fpage=7&highlight=&page=2

Automatic IP Change Version 2.0
http://www.cn-dos.net/forum/viewthread.php?tid=28621&fpage=2

Fully Automatic Machine Number and IP Setting Tool Version 3.0 (Full Version)
http://www.cn-dos.net/forum/viewthread.php?tid=32490&fpage=4

ip.bat
@set dbg=
@echo %dbg% off&setlocal enabledelayedexpansion
:: code by qasa copyright@qknet 2:16 2007-1-19
title Fully Automatic Machine Number and IP Setting Tool Author:qasa
set no_=0
mode con cols=40 lines=10&color fc
for /f "tokens=12 delims= " %%i in ('ipconfig /all^|find /i "Physical Address"') do (
set mac=%%i
set mac=!mac:~0,-1!
)
for /f "tokens=1-3 delims==|" %%j in (MAC.INI) do (
set mac_=%%j
set ip_=%%k
set sm_=%%l
if !mac! equ !mac_! (
call :set_ !mac_! !ip_! !sm_!
set /a no_+=1
)
)
if "!no_!"=="0" (
echo.&echo There is no MAC address of this machine in MAC.ini, and it will be sent to the work machine......
echo %date% %time% Newly discovered MAC address:>>NewMAC.ini&echo !mac! >>NewMAC.ini
echo.&echo Has been sent to the work machine! ! !
)
start shutdown -r -t 40
echo.
set/p zz_= Press Q key to exit the shutdown state:
if /i !zz_! equ q (start shutdown -a)
ping/n 5 127.1>nul
exit /b

:set_
echo %1 %2 %3
set yy_=%3
echo.&echo Is setting IP and machine number for %yy_:~1,3% number...... Please wait
for /f "tokens=1-4 delims==|" %%e in (DNS.ini) do (
set dns1_=%%e
set dns2_=%%f
set workgate_=%%g
set zwym_=%%h
)
for /l %%w in (1,1,2) do (
netsh interface IP Set Address "Local Area Connection" Static %2 %zwym_% %workgate_% 1 >nul
)
netsh interface IP Set Dns "Local Area Connection" static %dns1_% >nul
netsh interface ip add dns "Local Area Connection" %dns2_% >nul
REG ADD HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName /v "ComputerName" /t REG_SZ /d %3 /f >nul 2>NUL
REG ADD HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName /v "ComputerName" /t REG_SZ /d %3 /f >nul 2>NUL
REG ADD HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters /v "Hostname" /t REG_SZ /d %3 /f >nul 2>NUL
REG ADD HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters /v "NV Hostname" /t REG_SZ /d %3 /f >nul 2>NUL
echo.&echo Setting completed
goto :eof


MAC.ini
00-0A-EB-21-A7-EC=192.168.0.5|-005
00-E0-4C-8F-11-4A=192.168.0.6|-006
00-0A-EB-A0-1D-9A=192.168.0.7|-007
00-40-05-14-E7-C9=192.168.0.8|-008
00-0A-EB-A0-1C-7A=192.168.0.9|-009
00-0D-87-F2-03-50=192.168.0.10|-010
00-0D-87-F2-A3-5C=192.168.0.11|-011


DNS.ini
202.96.128.86=202.96.128.186|192.168.0.1|255.255.255.0


Just modify MAC.ini and DNS.ini according to your actual requirements. :P

[ Last edited by qasa on 2007-8-5 at 02:45 PM ]
Recent Ratings for This Post ( 11 in total) Click for details
RaterScoreTime
redtek +9 2007-01-19 21:38
hsting +2 2007-01-20 07:06
lxmxn +4 2007-01-20 07:09
everest79 +4 2007-01-20 13:40
561808275 +1 2007-01-21 04:15
429499381 +1 2007-01-24 15:03
htysm +2 2007-02-15 22:46
oilio +3 2007-02-25 00:22
ran520 +1 2007-03-01 10:32
colorphoto +2 2007-05-03 09:57
lzmuhioin +1 2007-10-05 20:36
Attachments
全自动设置机号、IP工具.rar (1.27 KiB, Credits to download 1 pts, Downloads: 567)
κχυμγνξοθπρωψιαδλεηφβτζσ┬╀┾┳┞┯┰┱┣┲┳╂╁│├┟┭┠这是什么??这就是我的人生
Floor 2 Posted 2007-01-19 17:43 ·  中国 广东 湛江 电信
高级用户
★★★
Credits 959
Posts 311
Joined 2006-04-11 14:08
20-year member
UID 53665
Gender Male
From 广东-LianJiang
Status Offline
echo %date% %time%Newly discovered MAC address:>>NewMAC.ini&echo !mac! >>NewMAC.ini
NewMAC.ini can be changed to \\Server address\Shared directory\NewMAC.ini
Floor 3 Posted 2007-01-19 17:46 ·  中国 广东 湛江 电信
高级用户
★★★
Credits 959
Posts 311
Joined 2006-04-11 14:08
20-year member
UID 53665
Gender Male
From 广东-LianJiang
Status Offline
I would like to express my gratitude to brother everest79 and brother lxmxn for their guidance.

[ Last edited by qasa on 2007-1-19 at 06:26 PM ]
Floor 4 Posted 2007-01-19 17:51 ·  中国 广东 湛江 电信
高级用户
★★★
Credits 959
Posts 311
Joined 2006-04-11 14:08
20-year member
UID 53665
Gender Male
From 广东-LianJiang
Status Offline
There is a strange thing during the test:

for /l %%w in (1,1,2) do (
netsh interface IP Set Address "Local Area Connection" Static %2 %zwym_% %workgate_% 1 >nul
)

If I don't loop twice, I need to run the program twice in a row to change the gateway. This needs to be guided by an expert.
Floor 5 Posted 2007-01-20 06:34 ·  中国 广东 湛江 遂溪县乌塘镇 电信
高级用户
★★★
Credits 959
Posts 311
Joined 2006-04-11 14:08
20-year member
UID 53665
Gender Male
From 广东-LianJiang
Status Offline
Why isn't there anyone supporting such a practical thing??
κχυμγνξοθπρωψιαδλεηφβτζσ┬╀┾┳┞┯┰┱┣┲┳╂╁│├┟┭┠这是什么??这就是我的人生
Floor 6 Posted 2007-01-20 06:39 ·  中国 广西 南宁 电信
初级用户
Credits 63
Posts 26
Joined 2006-12-31 00:38
19-year member
UID 75041
Gender Male
Status Offline
Push it up, study it
Floor 7 Posted 2007-01-20 07:10 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

I'm glad about this original work of yours, plus points~
Floor 8 Posted 2007-01-20 10:57 ·  中国 广东 湛江 电信
高级用户
★★★
Credits 959
Posts 311
Joined 2006-04-11 14:08
20-year member
UID 53665
Gender Male
From 广东-LianJiang
Status Offline
Hehe, thank you, senior, for recognizing my hard work.
κχυμγνξοθπρωψιαδλεηφβτζσ┬╀┾┳┞┯┰┱┣┲┳╂╁│├┟┭┠这是什么??这就是我的人生
Floor 9 Posted 2007-01-20 13:40 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
When testing, there is a strange thing. For the code:
for /l %%w in (1,1,2) do (
netsh interface IP Set Address "本地连接" Static %2 %zwym_% %workgate_% 1 >nul
)
If I don't loop...

The IP and mask are changed, but the gateway needs to be changed twice to take effect?
Floor 10 Posted 2007-01-20 13:43 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
Why doesn't the LZ put dns.ini and mac.ini together with the batch file? The three files are a bit messy.

::D=202.96.128.86=202.96.128.186|192.168.0.1|255.255.255.0
::M=00-0A-EB-21-A7-EC=192.168.0.5|-005
...........
Floor 11 Posted 2007-01-20 14:29 ·  中国 广东 湛江 电信
高级用户
★★★
Credits 959
Posts 311
Joined 2006-04-11 14:08
20-year member
UID 53665
Gender Male
From 广东-LianJiang
Status Offline
Originally posted by everest79 at 2007-1-20 13:43:
Why doesn't the LZ put dns.ini and mac.ini together with the batch file? The three files are a bit messy

::D=202.96.128.86=202.96.128.186|192.168.0.1|255.255.255.0
::M=00-0A-EB-21-A7-EC=192.168.0.5|-005 ...


This is for easy understanding and convenient modification, to avoid accidentally changing other parts when modifying the MAC address; the most important thing is that whoever sees it will know how to use it, which is the most important. Hehe
Recent Ratings for This Post ( 3 in total) Click for details
RaterScoreTime
czwlay +1 2007-01-20 15:10
everest79 +4 2007-01-20 17:32
561808275 +1 2007-01-21 04:15
κχυμγνξοθπρωψιαδλεηφβτζσ┬╀┾┳┞┯┰┱┣┲┳╂╁│├┟┭┠这是什么??这就是我的人生
Floor 12 Posted 2007-01-20 23:25 ·  IANA 局域网IP(Private-Use)
初级用户
★★
Credits 136
Posts 59
Joined 2006-06-02 16:05
20-year member
UID 56438
Status Offline
Thanks
Floor 13 Posted 2007-01-21 04:49 ·  中国 广东 湛江 电信
新手上路
Credits 6
Posts 3
Joined 2007-01-21 04:13
19-year member
UID 77193
Gender Male
Status Offline
The LZ really thinks about newbies. I can't bear to not top it~~~~~
This program is really a great help in internet cafes, reducing a lot of work. Awesome
Floor 14 Posted 2007-01-21 09:09 ·  中国 广东 湛江 电信
高级用户
★★★
Credits 959
Posts 311
Joined 2006-04-11 14:08
20-year member
UID 53665
Gender Male
From 广东-LianJiang
Status Offline
After debugging, when changing the computer name, these two lines of statements can be deleted without affecting the operation

REG ADD HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName /v "ComputerName" /t REG_SZ /d %3 /f >nul 2>NUL
REG ADD HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName /v "ComputerName" /t REG_SZ /d %3 /f >nul 2>NUL
κχυμγνξοθπρωψιαδλεηφβτζσ┬╀┾┳┞┯┰┱┣┲┳╂╁│├┟┭┠这是什么??这就是我的人生
Floor 15 Posted 2007-01-24 07:09 ·  中国 广东 湛江 电信
高级用户
★★★
Credits 959
Posts 311
Joined 2006-04-11 14:08
20-year member
UID 53665
Gender Male
From 广东-LianJiang
Status Offline
I'll give it a self-promotion to help those in need see this post, hehee
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
+1 2009-09-18 06:47
κχυμγνξοθπρωψιαδλεηφβτζσ┬╀┾┳┞┯┰┱┣┲┳╂╁│├┟┭┠这是什么??这就是我的人生
1 2 3 10 Next ›
Forum Jump: