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 05:22
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Original] Automatic Machine Number and IP Setting Tool 3.0 (Full Version) View 9,650 Replies 69
Original Poster Posted 2007-07-26 17:29 ·  中国 广东 湛江 廉江市 电信
高级用户
★★★
Credits 959
Posts 311
Joined 2006-04-11 14:08
20-year member
UID 53665
Gender Male
From 广东-LianJiang
Status Offline

This version was written after continuous improvement and refinement in practice. It corrects previous bugs and possible omissions, and is also a relatively complete version. Thank you for everyone's support and attention.
Main code reference:
@echo %dbg% off&setlocal enabledelayedexpansion
:: code by qasa copyright@qknet 2:16 2007-7-26
title 自动改IP(自设重启次数) 作者:钟其栋
mode con cols=50 lines=10&color a
if not exist 次数.txt goto st_
if exist c:\ip\key.txt goto OK
if not exist 设置.txt goto do_
set /p sum_=<次数.txt
for /l %%i in (!sum_!,-1,1) do (
if exist c:\ip\off%%i.txt goto end
)
exit /b

:st_
del /q c:\ip\*.txt >nul 2>nul
set /p sum_=你准备重启电脑多少次后安装冰点(建议设2次以上)?
echo %sum_% >次数.txt
cd %USERPROFILE%\「开始」菜单\程序\启动\
copy c:\ip\ippp.lnk . >nul 2>nul
cd c:\ip\
echo.&echo 请重启进行系统备份! ! !
ping/n 7 127.1>nul
goto :eof

:do_
setlocal enabledelayedexpansion
set no_=0
cd.>设置.txt
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 MAC.ini中没有此机的MAC地址,将发送到工作机上......
echo %date% %time%新发现的MAC地址:>>NewMAC.ini&echo !mac! >>NewMAC.ini
echo %date% %time%新发现的MAC地址:>>\\游戏主机\full$\NewMAC.ini&echo !mac! >>\\游戏主机\full$\NewMAC.ini
echo.&echo 已经发送到工作机! ! !
del /q c:\ip\次数.txt
)
goto :eof

:set_
set /p w=<次数.txt
if %w% equ 1 cd.>c:\ip\key.txt&&start shutdown -r -t 90 -c 现在是第1次重启_最后一次重启_下次将安装冰点。作者:qasa
if %w% neq 1 start shutdown -r -t 90 -c 现在是第1次重启。
cd.>c:\ip\off2.txt
echo %1 %2 %3
set yy_=%3
echo.&echo 正在为%yy_:~1,3%号设置IP、机号...... 请稍候
for /f "tokens=1-4 delims==|" %%e in (DNS.ini) do (
set dns1_=%%e
set dns2_=%%f
set workgate_=%%g
set zwym_=%%h
)
for /f "tokens=1 delims=" %%s in ('ipconfig /all^|find /i "Ethernet adapter"') do (set ss_=%%s)
set ss_=%ss_:~17,-2%
for /l %%w in (1,1,2) do (
netsh interface IP Set Address "%ss_%" Static %2 %zwym_% %workgate_% 1 >nul
)
netsh interface IP Set Dns "%ss_%" static %dns1_% >nul
netsh interface ip add dns "%ss_%" %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 设置完毕
goto :eof

:end
setlocal EnableDelayedExpansion
set /p summ_=<次数.txt
set /p ss=<次数.txt
set /a sss=ss
for /l %%i in (!summ_!,-1,1) do (
if exist c:\ip\off%%i.txt (
set /a a=%%i
if exist c:\ip\off!sss!.txt (
start shutdown -r -t 60 -c 现在是第!a!次重启_最后一次重启_下次将安装冰点。作者:qasa
cd.>c:\ip\key.txt
goto :eof
)
start shutdown -r -t 60 -c 现在是第!a!次重启。
set/a b=a+1
cd.>c:\ip\off!b!.txt
goto :eof
)
)
goto :eof

:OK
cd %USERPROFILE%\「开始」菜单\程序\启动\
del /q ippp.lnk
cd c:\ip\
del /q c:\ip\*.txt
start "" df /install
goto :eof


Now attach the source code for everyone to study and give comments. There is also a usage instruction attached.

The first post was sent incorrectly, and the 2.0 version was uploaded. It has now been corrected. Those who have already downloaded it please re-download. Thank you.


[ Last edited by qasa on 2007-7-26 at 10:03 PM ]
Recent Ratings for This Post ( 3 in total) Click for details
RaterScoreTime
wudixin96 +15 2007-07-26 17:33
561808275 +1 2007-12-04 17:02
everest79 +15 2007-12-21 18:27
Attachments
自动改IP3.0源代码.rar (73.46 KiB, Credits to download 10 pts, Downloads: 353)
κχυμγνξοθπρωψιαδλεηφβτζσ┬╀┾┳┞┯┰┱┣┲┳╂╁│├┟┭┠这是什么??这就是我的人生
Floor 2 Posted 2007-07-26 17:32 ·  中国 浙江 杭州 电信
银牌会员
★★★
Credits 1,928
Posts 931
Joined 2007-01-06 11:46
19-year member
UID 75624
Gender Male
Status Offline
楼主名字:Zhong Qidong?

So long, headache!
Floor 3 Posted 2007-07-26 22:08 ·  中国 广东 湛江 廉江市 电信
高级用户
★★★
Credits 959
Posts 311
Joined 2006-04-11 14:08
20-year member
UID 53665
Gender Male
From 广东-LianJiang
Status Offline
Originally posted by wudixin96 at 2007-7-26 17:32:
The poster's name: Zhong Qidong?

So long, headache!



Exactly
κχυμγνξοθπρωψιαδλεηφβτζσ┬╀┾┳┞┯┰┱┣┲┳╂╁│├┟┭┠这是什么??这就是我的人生
Floor 4 Posted 2007-07-27 09:16 ·  中国 江苏 苏州 电信
初级用户
Credits 24
Posts 11
Joined 2007-07-13 10:36
18-year member
UID 93864
Gender Male
Status Offline
I feel that the modification method above is not very rigorous in some places. I specially provide the script I wrote.

@Echo off
Title Please waitting. update computer information.
set flName=c:\windows\ip.txt

set netMask=255.255.255.0
set Gateway=192.168.1.254
set Metric=1
set DNS1=61.177.7.1
set DNS2=221.228.255.1
set DNS3=218.2.135.1

IF EXIST D:\ %windir%\system32\CSCRIPT %windir%\system32\PAGEFILECONFIG.vbs /create /I 768 /M 1536 /VO d: >nul
if EXIST E:\ %windir%\system32\CSCRIPT %windir%\system32\PAGEFILECONFIG.vbs /create /I 512 /M 768 /VO E: >nul
IF EXIST C:\ %windir%\system32\CSCRIPT %windir%\system32\PAGEFILECONFIG.vbs /change /I 512 /M 768 /VO C: >nul
REM GET ComputerName,AdapName,Phyaddr
for /f "tokens=2 delims=:" %%a in ('ipconfig /all^|find "Host Name"') do set pcName=%%a
for /f "tokens=3 delims= " %%a in ('ipconfig /all^|find "Ethernet adapter"') do set AdapName=%%a
for /f "tokens=2 delims=:" %%a in ('ipconfig /all^|find "Physical Address"') do set PhyAddr=%%a
set pcName=%pcName:~1%
set AdapName=%AdapName:~0,-2%
set PhyAddr=%PhyAddr:~1%
set mac1=%PhyAddr:~0,2%
set mac2=%PhyAddr:~3,2%
set mac3=%PhyAddr:~6,2%
set mac4=%PhyAddr:~9,2%
set mac5=%PhyAddr:~12,2%
set mac6=%PhyAddr:~15,2%
set PhyAddr=%mac1%%mac2%%mac3%%mac4%%mac5%%mac6%
set wmicMac=%mac1%:%mac2%:%mac3%:%mac4%:%mac5%:%mac6%
:Echo %pcName% %AdapName% %PhyAddr%

REM Find ip-Mac addr @ file.
for /f "skip=2 tokens=1,2,3,4" %%a in ('find "%PhyAddr%" "%flName%"') do call :findok %%b %%a %%c
goto end
REM Change Computer name

REM

:setok
@Echo This computer's mac is: %1 ipaddress is: %2 name is: %3
@Echo Please waitting...
@Echo Now,update computer name
WMIC computersystem where Name="%pcName%" call Rename Name="%3" >nul
@Echo Modify ip address
WMIC NICCONFIG WHERE MACAddress="%wmicMac%" call EnableStatic("%2"),("%netMask%") >nul
WMIC NICCONFIG WHERE MACAddress="%wmicMac%" call SetGateways("%Gateway%") >nul
@Echo Modify DNS
WMIC NICCONFIG WHERE MACAddress="%wmicMac%" call SetDNSServerSearchOrder("%DNS1%", "%DNS2%", "%DNS3%") >nul
:end
@Echo All Done!

The basic structure of IP.txt:
192.168.1.1 001A928EFC1E PC001 WORKGROUP
192.168.1.2 001A9235D870 PC002 WORKGROUP
192.168.1.3 001A928EF04E PC003 WORKGROUP
192.168.1.4 001A9235B64D PC004 WORKGROUP
192.168.1.5 001A928EF37A PC005 WORKGROUP
192.168.1.6 001A928EF12E PC006 WORKGROUP
192.168.1.7 001A928EE291 PC007 WORKGROUP
192.168.1.8 001A928EE318 PC008 WORKGROUP
192.168.1.9 001A928EF187 PC009 WORKGROUP
192.168.1.10 001A928EF44A PC010 WORKGROUP
Black/White
Mono
CGA
VGA
SVGA
LCD
十年工龄 For disk operation system
Floor 5 Posted 2007-07-27 09:20 ·  中国 江苏 苏州 电信
初级用户
Credits 24
Posts 11
Joined 2007-07-13 10:36
18-year member
UID 93864
Gender Male
Status Offline
All achieved by WMIC to modify computer name, IP address, gateway, DNS server.

Also create Pagefile.sys page files on drives C, D, E respectively, which can prevent formatting.

IP.txt is also reused in multiple places. On the DHCP server, use For /f .... do netsh dhcp server *** scope *** add reservedip ip mac to bind MAC to IP, etc.
Black/White
Mono
CGA
VGA
SVGA
LCD
十年工龄 For disk operation system
Floor 6 Posted 2007-07-31 21:59 ·  中国 江苏 淮安 联通
初级用户
Credits 28
Posts 10
Joined 2007-07-31 21:20
18-year member
UID 94396
Gender Male
Status Offline
Study, study, and keep studying
Floor 7 Posted 2007-08-01 00:22 ·  中国 浙江 衢州 电信
新手上路
Credits 18
Posts 9
Joined 2006-08-16 17:40
19-year member
UID 60657
Gender Male
Status Offline
Practical good stuff, thank you to the original poster.
Floor 8 Posted 2007-08-01 19:43 ·  中国 山东 东营 联通
新手上路
Credits 10
Posts 3
Joined 2005-07-30 09:18
20-year member
UID 41189
Status Offline
Thanks for sharing, let's give it a try.
Floor 9 Posted 2007-08-02 03:16 ·  中国 广西 钦州 灵山县 电信
初级用户
Credits 75
Posts 36
Joined 2007-05-11 10:12
19-year member
UID 88144
Gender Male
Status Offline
Good stuff, can it be smaller?
Floor 10 Posted 2007-08-09 14:25 ·  中国 浙江 台州 三门县 电信
新手上路
Credits 11
Posts 5
Joined 2007-07-27 21:27
18-year member
UID 94149
Gender Male
Status Offline
This one is wanted, but the points are not enough, heh heh
Floor 11 Posted 2007-08-09 14:26 ·  中国 浙江 台州 三门县 电信
新手上路
Credits 11
Posts 5
Joined 2007-07-27 21:27
18-year member
UID 94149
Gender Male
Status Offline
Just reply again and you can download it.
Floor 12 Posted 2007-08-09 14:34 ·  中国 湖南 郴州 电信
初级用户
Credits 32
Posts 13
Joined 2007-04-14 03:23
19-year member
UID 85080
Gender Male
Status Offline
How fully automatic is it? Let's download and take a look.
Floor 13 Posted 2007-08-31 18:26 ·  中国 北京 电信
新手上路
Credits 10
Posts 5
Joined 2007-08-31 17:07
18-year member
UID 96268
Gender Male
Status Offline
Good stuff
Floor 14 Posted 2007-09-03 10:36 ·  中国 上海 电信
初级用户
Credits 40
Posts 17
Joined 2007-08-10 14:49
18-year member
UID 94928
Gender Male
Status Offline
No money, the owner can send me a copy??lxsky@263.net
Floor 15 Posted 2007-09-05 21:21 ·  中国 上海 东方有线
初级用户
Credits 40
Posts 17
Joined 2007-08-10 14:49
18-year member
UID 94928
Gender Male
Status Offline
1 2 3 5 Next ›
Forum Jump: