复制代码
- @echo off
- setlocal enabledelayedexpansion
- ———————————————————————————————————————————————————————————————
- cls
- if not exist c:\user-ip.txt (echo txterror & 1pause & exit)
- echo nextok
- 1pause
- cls
- for /f "delims=" %%i in (c:\user-ip.txt) do (
- set /a j+=1
- if !j!==1 set nana=%%i
- if !j!==2 set ipip=%%i
- )
- ———————————————————————————————————————————————————————————————
- cls
- echo %nana%------
- echo %ipip%------
- 1pause
- cls
- set Mask=255.255.255.128
- set Gway=192.168.8.1
- :status
- cls
- @ECHO OFF&Setlocal EnableDelayedExpansion
- set _Name=计算机名----&set _Domain=工作组------&set _IPAddress=IP地址------
- set _IPSubnet=子网掩码----&set _DefaultIPGateway=网关--------&set _DNSServerSearchOrder=DNS---------
- FOR /F "tokens=*" %%A IN ('WMIC Path Win32_ComputerSystem Get Domain^,Name /Value 2^>Nul') DO (
- FOR /F "tokens=*" %%i in ("%%A") do set %%i
- )
- echo %Name%------
- echo %IPAddress%------
- 1pause
- cls
- FOR /F "tokens=*" %%A IN ('WMIC NICConfig WHERE "IPEnabled=TRUE" GET DefaultIPGateway^,Description^,DNSServerSearchOrder^,IPAddress^,IPSubnet /value 2^>Nul') DO (
- FOR /F "tokens=*" %%i in ("%%A") do set %%i
- )
- echo %Name%------
- echo %IPAddress%------
- 1pause
- cls
- for %%i in (Name IPAddress IPSubnet DefaultIPGateway) do (
- set %%i=!%%i:{=!
- set %%i=!%%i:}=!
- set %%i=!%%i:"=!
- echo !_%%i!: !%%i:,= !
- 1pause
- cls
- )
- echo %Name%=========
- echo %IPAddress%=========
- 1pause
- cls
- if "%name%"=="%nana%" (
- if "%IPAddress%"=="%ipip%" goto :cbsnext
- )
- echo nene
- 1pause
- cls
- cls
- echo 计算机名:%nana%
- echo ip地址:%ipip%
- echo 正在修改中...
- 1pause
- cls
- ping 127.0.0.1 -n 2 >nul 2>nul
- ———————————————————————
- cls
- reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName" /v "ComputerName" /t reg_sz /d %nana% /f >nul 2>nul
- reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ActiveComputerName" /v "ComputerName" /t reg_sz /d %nana% /f >nul 2>nul
- reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v "NV Hostname" /t reg_sz /d %nana% /f >nul 2>nul
- reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v "Hostname" /t reg_sz /d %nana% /f >nul 2>nul
- reg add "HKLM\SYSTEM\ControlSet001\Control\ComputerName\ActiveComputerName" /v "ComputerName" /t REG_SZ /d "%nana%" /f
- reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v "NV Hostname" /t REG_SZ /d "%nana%" /f
- reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v "Hostname" /t REG_SZ /d "%nana%" /f
- reg add "HKLM\SYSTEM\ControlSet002\Control\ComputerName\ComputerName" /v "ComputerName" /t REG_SZ /d "%nana%" /f
- ———————————————————————
- cls
- ::用ipconfig /all命令获取网卡名称。
- cls
- FOR /F "tokens=2*" %%i IN ('ipconfig/all^|find /i "Ethernet adapter "') DO set macname=%%j
- ::用for命令删除网卡名称后面的冒号。
- cls
- FOR /F "tokens=1* delims=:" %%i in ("%macname%") do set a=%%i
- echo 网卡连接名:%a%
- cls
- 1pause
- cls
- netsh interface ip set address name="%a%" source=static addr=%ipip% mask=%Mask% gateway=%Gway% gwmetric=1 >nul 2>nul
- cls
- 1pause
- cls
- shutdown -r -t 2
- :cbsnext
- ———————————————————————
- echo user-ip文件夹中的与本地机器获取到的一致
- echo okok
- 1pause
- cls
- exit
复制代码
- @echo off
- :star
- setlocal enabledelayedexpansion
- ———————————————————————————————————————————————————————————————
- cls
- if not exist c:\user-ip.txt (echo txterror & 1pause & exit)
- echo nextok
- 1pause
- cls
- for /f "delims=" %%i in (c:\user-ip.txt) do (
- set /a j+=1
- if !j!==1 set nana=%%i
- if !j!==2 set ipip=%%i
- )
- ———————————————————————————————————————————————————————————————
- cls
- echo %nana%------
- echo %ipip%------
- 1pause
- cls
- set Mask=255.255.255.128
- set Gway=192.168.8.1
- :status
- cls
- @ECHO OFF&Setlocal EnableDelayedExpansion
- set _Name=计算机名----&set _Domain=工作组------&set _IPAddress=IP地址------
- set _IPSubnet=子网掩码----&set _DefaultIPGateway=网关--------&set _DNSServerSearchOrder=DNS---------
- FOR /F "tokens=*" %%A IN ('WMIC Path Win32_ComputerSystem Get Domain^,Name /Value 2^>Nul') DO (
- FOR /F "tokens=*" %%i in ("%%A") do set %%i
- )
- echo %Name%------
- echo %IPAddress%------
- 1pause
- cls
- FOR /F "tokens=*" %%A IN ('WMIC NICConfig WHERE "IPEnabled=TRUE" GET DefaultIPGateway^,Description^,DNSServerSearchOrder^,IPAddress^,IPSubnet /value 2^>Nul') DO (
- FOR /F "tokens=*" %%i in ("%%A") do set %%i
- )
- echo %Name%------
- echo %IPAddress%------
- 1pause
- cls
- for %%i in (Name IPAddress IPSubnet DefaultIPGateway) do (
- set %%i=!%%i:{=!
- set %%i=!%%i:}=!
- set %%i=!%%i:"=!
- echo !_%%i!: !%%i:,= !
- 1pause
- cls
- )
- echo %Name%=========
- echo %IPAddress%=========
- 1pause
- cls
- if "%name%"=="%nana%" (
- if "%IPAddress%"=="0.0.0.0" goto :cbsnetn
- if "%IPAddress%"=="%ipip%" goto :cbsnext
- )
- echo nene
- 1pause
- cls
- cls
- echo 计算机名:%nana%
- echo ip地址:%ipip%
- echo 正在修改中...
- 1pause
- cls
- ping 127.0.0.1 -n 2 >nul 2>nul
- ———————————————————————
- cls
- reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName" /v "ComputerName" /t reg_sz /d %nana% /f >nul 2>nul
- reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ActiveComputerName" /v "ComputerName" /t reg_sz /d %nana% /f >nul 2>nul
- reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v "NV Hostname" /t reg_sz /d %nana% /f >nul 2>nul
- reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v "Hostname" /t reg_sz /d %nana% /f >nul 2>nul
- reg add "HKLM\SYSTEM\ControlSet001\Control\ComputerName\ActiveComputerName" /v "ComputerName" /t REG_SZ /d "%nana%" /f
- reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v "NV Hostname" /t REG_SZ /d "%nana%" /f
- reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v "Hostname" /t REG_SZ /d "%nana%" /f
- reg add "HKLM\SYSTEM\ControlSet002\Control\ComputerName\ComputerName" /v "ComputerName" /t REG_SZ /d "%nana%" /f
- ———————————————————————
- cls
- ::用ipconfig /all命令获取网卡名称。
- cls
- FOR /F "tokens=2*" %%i IN ('ipconfig/all^|find /i "Ethernet adapter "') DO set macname=%%j
- ::用for命令删除网卡名称后面的冒号。
- cls
- FOR /F "tokens=1* delims=:" %%i in ("%macname%") do set a=%%i
- echo 网卡连接名:%a%
- cls
- 1pause
- cls
- netsh interface ip set address name="%a%" source=static addr=%ipip% mask=%Mask% gateway=%Gway% gwmetric=1 >nul 2>nul
- cls
- 1pause
- cls
- shutdown -r -t 2
- :cbsnetn
- echo neterror
- 1pause
- cls
- ping 127.0.0.1 -n 120 >nul 2>nul
- goto :star
- :cbsnext
- echo okok
- 1pause
- cls
- exit
欢迎光临 批处理之家 (http://www.bathome.net/) | Powered by Discuz! 7.2 |