![]() |
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-25 23:44 |
47,812 topics / 349,910 posts / today 0 new / 48,264 members |
| DOS批处理 & 脚本技术(批处理室) » Batch scripts for changing IP and machine number, commonly used in internet cafes! |
| Printable Version 4,045 / 12 |
| Floor1 wmysbbs | Posted 2007-01-10 07:34 |
| 初级用户 Posts 52 Credits 172 | |
|
Let everyone laugh, I think there are too many codes, it should still be able to be simplified, but I have low level!
I don't know if the expert can simplify the code! Also, the subnet mask and backup DNS cannot be displayed, does any expert know how to do it? @echo off mode con cols=80 lines=30 :top title ………………………………………………IP Modifier……………………………………………… cls color 0a :::::::::::::::::::::::::::::::::::::::::::::: :Check IP, Gateway, DNS @echo off setlocal enabledelayedexpansion set IP_num=0 set Gateway_num=0 set DNS_num=0 for /f "tokens=2* delims=:" %%i in ('ipconfig /all ^| find /i "IP Address"') do ( for /f "tokens=2* delims=:" %%a in ('ipconfig /all ^| find /i "Default Gateway"') do ( for /f "tokens=2* delims=:" %%1 in ('ipconfig /all ^| find /i "DNS Servers"') do ( set IP_=%%i set Gateway_=%%a set DNS_=%%1 if "!IP_num!"=="0" set IP2=!IP_:~1! if "!Gateway_num!"=="0" set Gateway2=!Gateway_:~1! if "!DNS_num!"=="0" set DNS2=!DNS_:~1! set /a IP_num=!IP_num!+1 set /a Gateway_num=!Gateway_num!+1 set /a DNS_num=!DNS_num!+1 ) ) ) CLS :::::::::::::::::::::::::::::::::::::::::::::: echo. echo IP Modifier QQ:82288252 echo ================================================================================ echo Local Information: echo Computer Name: %userdomain% echo Local IP: %IP2% echo Local Gateway: %Gateway2% echo Local DNS: %DNS2% echo. set /p n= Enter local number (Q to quit): if %n% equ q exit echo. echo The number you entered is: %n% echo. set /p x= How many bits to offset the IP number: set /a ip = %n% + %x% echo. echo Modifying, please wait... :::::::::::::::::::::::::::::::::::::::::::::: :Generate VBS script to modify IP echo strIPAddress = Array(^"192.168.1.%IP%^") ^'Modified ip >>ip.vbe echo strSubnetMask = Array(^"255.255.255.0^") ^'Subnet mask >>ip.vbe echo strGateway = Array(^"192.168.1.1^") ^'Gateway >>ip.vbe echo arrDNSServers = Array(^"202.103.224.68^", ^"202.103.225.68^")^'DNS >>ip.vbe echo strComputer = ^".^" >>ip.vbe echo. >>ip.vbe echo Set objWMIService = GetObject(^"winmgmts:^\\^" ^& strComputer ^& ^"^\root^\cimv2^") >>ip.vbe echo Set colNetAdapters = objWMIService.ExecQuery _ >>ip.vbe echo (^"Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE^") >>ip.vbe echo. >>ip.vbe echo For Each objNetAdapter in colNetAdapters >>ip.vbe echo sip=objNetAdapter.IPAddress >>ip.vbe echo ^'strIPAddress = sip ^'Keep original ip >>ip.vbe echo. >>ip.vbe echo strGatewayMetric = Array(1) >>ip.vbe echo errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask) >>ip.vbe echo errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric) >>ip.vbe echo errDNS=objNetAdapter.SetDNSServerSearchOrder(arrDNSServers) >>ip.vbe echo exit for ^'Only modify the settings of the first network card >>ip.vbe echo Next >>ip.vbe :::::::::::::::::::::::::::::::::::::::::::::: :Replace actual computer name with variable %n% echo Windows Registry Editor Version 5.00 >Computer Name.reg echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters] >>Computer Name.reg echo "NV Hostname"="%n%" >>Computer Name.reg echo "Hostname"="%n%" >>Computer Name.reg :::::::::::::::::::::::::::::::::::::::::::::: :Import registry file regedit /s Computer Name.reg :::::::::::::::::::::::::::::::::::::::::::::: :Run VBE file to change IP address ip.vbe :::::::::::::::::::::::::::::::::::::::::::::: :Delete reg and vbe files del Computer Name.reg del ip.vbe :::::::::::::::::::::::::::::::::::::::::::::: :Recheck IP, Gateway, DNS @echo off setlocal enabledelayedexpansion set IP_num=0 set Gateway_num=0 set DNS_num=0 for /f "tokens=2* delims=:" %%i in ('ipconfig /all ^| find /i "IP Address"') do ( for /f "tokens=2* delims=:" %%a in ('ipconfig /all ^| find /i "Default Gateway"') do ( for /f "tokens=2* delims=:" %%1 in ('ipconfig /all ^| find /i "DNS Servers"') do ( set IP_=%%i set Gateway_=%%a set DNS_=%%1 if "!IP_num!"=="0" set IP2=!IP_:~1! if "!Gateway_num!"=="0" set Gateway2=!Gateway_:~1! if "!DNS_num!"=="0" set DNS2=!DNS_:~1! set /a IP_num=!IP_num!+1 set /a Gateway_num=!Gateway_num!+1 set /a DNS_num=!DNS_num!+1 ) ) ) CLS :::::::::::::::::::::::::::::::::::::::::::::: echo. echo IP Modifier QQ:82288252 echo ================================================================================ echo Modification Successful: echo. echo Current Local Information: echo Computer Name: %userdomain% This item takes effect after restart echo Local IP: %IP2% echo Local Gateway: %Gateway2% echo Local DNS: %DNS2% echo. :Press any key to exit @pause |
|
| Floor2 utem999 | Posted 2007-01-10 08:06 |
| 初级用户 Posts 54 Credits 135 | |
|
Thanks
Very practical bat+vbs+reg |
|
| Floor3 a2f6k8 | Posted 2007-01-10 10:47 |
| 初级用户 Posts 12 Credits 30 | |
|
Oh, what a pain... Such batch processing isn't practical in internet cafes nowadays. The most awesome thing is full automation... First, scan all IPs and MAC addresses of all machines, collect and save them. Then compile a P processing, get the MAC, then judge and find a matching one from the scanned MACs, and then change it to the set IP and computer name. That's what's considered advanced...
|
|
| Floor4 a2f6k8 | Posted 2007-01-10 10:48 |
| 初级用户 Posts 12 Credits 30 | |
|
However, I have to thank the LZ... I've learned this batch processing again...
|
|
| Floor5 wmysbbs | Posted 2007-01-10 18:05 |
| 初级用户 Posts 52 Credits 172 | |
Originally posted by a2f6k8 at 2007-1-10 10:47 AM: Hehe, you have to say, when we install a new internet cafe, there are no client machines, only one machine for you to make the master disk. Where do you get the MAC address? The set you mentioned is used in our own alliance internet cafe! I post it just for everyone to study and have a reference! There are also special small software for changing IP, but I don't like using third-party software! This is based on the situation here! Everyone is different, and fully automatic is not the best! It's enough if it works! Don't you think so? [ Last edited by wmysbbs on 2007-1-10 at 06:08 PM ] |
|
| Floor6 mouzeming | Posted 2007-01-11 04:07 |
| 初级用户 Posts 28 Credits 66 | |
|
@echo off
set /p e=Please enter the IP segment: set /p var=Please enter the computer name: cls reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName" /v ComputerName /t reg_SZ /d %var% /f >nul reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName" /v ComputerName /t reg_SZ /d %var% /f >nul reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" /v Hostname /t reg_SZ /d %var% /f >nul reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" /v "NV Hostname" /t reg_SZ /d %var% /f >nul @for %%n in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do call set var=%%var:%%n=%% :loop @if "%var:~0,1%" == "0" set var=%var:~1% netsh interface ip set address name="Local Area Connection" source=static addr=192.168.%e%.%var% mask=255.255.255.0 gateway=192.168.%e%.1 gwmetric=0 >nul netsh interface ip set dns name="Local Area Connection" source=static addr=61.187.191.3 register=PRIMARY >nul netsh interface ip add dns name="Local Area Connection" addr=202.103.96.68 index=2 >nul if %var% lss 14 goto cdkey1 if %var% lss 21 goto cdkey2 if %var% lss 28 goto cdkey3 if %var% lss 35 goto cdkey4 if %var% lss 42 goto cdkey5 if %var% lss 49 goto cdkey6 if %var% lss 56 goto cdkey7 goto :eof :cdkey1 reg add "HKEY_CURRENT_USER\Software\Valve\Half-Life\Settings" /v ValveKey /t reg_sz /d 5RP2E-EPH3K-BR3LG-KMGTE-FN8PY /f goto :IP :cdkey2 reg add "HKEY_CURRENT_USER\Software\Valve\Half-Life\Settings" /v ValveKey /t reg_sz /d ULPF-ZEVK-FRWG-Q4YJ-6F2T /f goto :IP :cdkey3 reg add "HKEY_CURRENT_USER\Software\Valve\Half-Life\Settings" /v ValveKey /t reg_sz /d Y83K-CT4F-VL2X-4X4M-SW8X /f goto :IP :cdkey4 reg add "HKEY_CURRENT_USER\Software\Valve\Half-Life\Settings" /v ValveKey /t reg_sz /d 2LMD-5MUD-UY2Y-SUU2-2UUQ /f goto :IP :cdkey5 reg add "HKEY_CURRENT_USER\Software\Valve\Half-Life\Settings" /v ValveKey /t reg_sz /d WVNN-XDK3-PZ6Q-PN42-W9G7 /f goto :IP :cdkey6 reg add "HKEY_CURRENT_USER\Software\Valve\Half-Life\Settings" /v ValveKey /t reg_sz /d YM2S-PVC6-RL2T-UT89-SW8T /f goto :IP :cdkey7 reg add "HKEY_CURRENT_USER\Software\Valve\Half-Life\Settings" /v ValveKey /t reg_sz /d 4EFF-YZNG-6AS4-3QJQ-44YG /f :IP @echo Current computer-related configuration: @echo ................................................................................ @echo off for /f "tokens=15" %%i in ('ipconfig /all ^| find /i "ip address"') do set ip=%%i @echo Local IP:%ip% @echo ................................................................................ for /f "tokens=15" %%i in ('ipconfig /all ^| find /i "Subnet Mask"') do set SM=%%i @echo Local subnet mask:%sm% @echo ................................................................................ for /f "tokens=1* delims=:" %%i in ('ipconfig /all^|find /i "Default Gateway"') do set DG=%%j @echo Local default gateway:%DG% @echo ................................................................................ for /f "tokens=15" %%i in ('ipconfig /all ^| find /i "DNS server"') do set DS=%%i @echo Local DNS server:%DS% @echo ................................................................................ @echo Backup DNS server:202.103.96.68 @echo ................................................................................ for /f "tokens=16" %%i in ('ipconfig /all ^| find /i "Host Name"') do set HN=%%i @echo Computer name is :%HN% @echo ................................................................................ @echo Press any key to perform network test. @pause >nul @ping 61.187.191.3 @echo Test completed.. Press any key to exit. @pause > nul I wrote it after using it for a while. Also, because I need to make a Internet café system. Like the building owner, I don't like to use any IP modification tools. Of course, I did it according to some local network settings. For example, DNS. Enter the segment just enter a number. For example, if your gateway is 192.168.1.1, then you enter "1". The IP is changed according to the computer name. IF the computer name is a046, then the IP is 192.168.1.46. For the CDKEY of CS, just look at it. Just started learning. I hope everyone doesn't laugh. The content is a bit low-intelligence |
|
| Floor7 harveyliu | Posted 2007-01-11 05:15 |
| 新手上路 Posts 2 Credits 6 | |
|
Excuse me, can the above code run under the user permissions of Windows 2000 or XP?
|
|
| Floor8 mouzeming | Posted 2007-01-11 10:13 |
| 初级用户 Posts 28 Credits 66 | |
| Floor9 hjc0759 | Posted 2007-03-08 21:47 |
| 新手上路 Posts 1 Credits 2 | |
|
Good
|
|
| Floor10 shikx2008 | Posted 2007-03-08 22:17 |
| 初级用户 Posts 28 Credits 57 From 中国 | |
|
Not bad, very good? I want to write but don't know how, not very understanding, and I'm learning batch processing. Thanks to the landlord, I've learned a lot.
|
|
| Floor11 429499381 | Posted 2007-03-16 09:27 |
| 中级用户 Posts 202 Credits 452 | |
|
The principle is very simple!! But it's very practical. Actually, sometimes it's just about re-burning the system disk. You can completely make a batch file and put it on the D drive. First, collect the local IP-related information, and then after burning the system disk well, run this batch file to restore the previous IP ==. Moreover, what you have now is obviously used after hard disk cloning, but there is no boot auto-start, and it deletes itself automatically after setting ==. Also, someone has already made one before you, you can go and have a look
http://cn-dos.net/forum/viewthread.php?tid=26870&fpage=1&highlight=IP |
|
| Floor12 duzhuoshu | Posted 2007-05-30 15:59 |
| 初级用户 Posts 9 Credits 20 | |
|
Sometimes it works, sometimes it doesn't
|
|
| Floor13 qq43142691 | Posted 2007-05-30 19:17 |
| 中级用户 Posts 152 Credits 326 | |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |