2023年11月26日发(作者:)

dazhu10/blog/static/

366007152008102003850553/

根据MAC自动更改计机名IP

一些错误信息解决方法:

1C:>wmic path win32_pnpsigneddriver

节点 - s-151

错误:

描述 = 提供程序加载

解决方法:是msinfo.dll没有注的问题,l.com上下载一个ms

复制到"%SystemRoot%pchealthhelpctrbinaries"目录重新注册ok

2C:>wmic path win32_pnpsigneddriver

错误:

代码 = 0x8007007e

说明 = 找不到制定的

设备 = win32

解决方法:暂时未知

网上一段说明

forums.microso/china/ShowPos?PostID=1971041&SiteID=15

出现 error 0x8007007e消息

原因:通常是因为系中的Urlm文件和Cabinwr.dll文件丢或者没有注引起

.

解决:

XP: 运行 SFC 替换这两个文即可. 运行 Sfc /Scanonce

Win2K :

1.运行: Regsvr32 urlmon.dll 如果还是不行,请尝试以下的:

2.进入[控制面板→添加/删除程序],选择 Microsoft Internet Explorer 后单击 [

/删除]按钮,选择 [修复Internet Explorer],并跟随指示进修复即可.

3.尝试安装Microsoft XML Parser最新版本,当前版本是Microsoft XML Parser3.0

sp2.

:

o/downloads/details.aspx?FamilyId=B1AD2C0A-8CC6-443B-AB8

3-F8516C72FAC1&displaylang=en

将下面的文本制到批命令执行

@echo off & SETLOCAL ENABLEDELAYEDEXPANSION

:::::::::::::::::::::::::::::::::::::::::::::::::::

::auto_set_ip_v

::根据mac自动修改ip地址、网关、dns、计算机名、工作组等

::code by:vkill

:::::::::::::::::::::::::::::::::::::::::::::::::::

::更新记录

::2008.07.01 v1.0 完成基本的功

::2008.07.04 v1.2 修改ip地址原来的netsh命令转wmic

:: 增加修改工作功能

:: 增加可以按照ip来得到自得到标准mask

:: 增加自动判断理网卡型号

:: 增加了可不修dns 网关等判断

::2008.07.06 v1.4 去掉了devcon外部命的支持,全部使用wmic来完成

:: 在配置ip加了确认信,用了一个等待户确认的高用法

:: 增加记录ip配置日志功

:: 增加了备份ip信息功能

:: 增加了可自定数据库存放本脚本还是部文件中的

::2008.07.08 v1.6 修正匹配网卡号时条件太的问题

:: 增加如安装有物理网卡时你选择的功

:: 增加修改ipdns等根据回值判断是修改成功

:: 去掉备份准配信息的功能

::2008.07.09 v1.7 修正了因为是统缺少dll而提示找不网卡的问题

:::::::::::::::::::::::::::::::::::::::::::::::::::

:::::::::::::::::::::::::::::::::::::::::::::::::::

::变量设置

:::::::::::database_start::::::::::

:::::::::database_end::::::::::::之间的数据复到制定的文

set "datebase="

::如果要把数据存放在本脚内就把下面 ::set "datebase=%~0" 的注释去掉

set "datebase=%~0"

set "t=%random%"

:::::::::::::::::::::::::::::::::::::::::::::::::::

goto :start_

:::::::::::::::::::::::::::::::::

:::::::::database_start::::::::::

:::::::::::::::::::::::::::::::::

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;readme

;注意:分隔符是 [tab],可用excel打开来修改

;mac_address---- : - ( 00:01:23:45:67:89

00-01-23-45-67-89 )

;enabledhcp----(0/1),如为1表示将置为dhcp,后面的addr mask等等不生效,为0

则反之

;mask----如设置为standard那么将根据你置的ip自动来计算设置为标准

mask,如想用子网,那么这里就照况写,如255.255.255.224

;mac_address / enabledhcp / addr / mask ----这四项必须

;hostname / workgroup / gateway / dns_primary / dns_second ----各项,如不想修改,

保持原样,可写为 none

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;mac_address hostname workgroup enabledhcp addr mask gateway dns_primary dns_second

;00:01:23:45:67:89 test myhost 0 192.168.251.100 standard 192.168.251.254

202.100.64.68 202.100.64.66

00-e0-4c-0b-f4-3c admin myhost 0 192.168.251.116 standard 192.168.251.254

192.168.251.254 202.100.64.68

:::::::::::::::::::::::::::::::::

:::::::::database_end::::::::::::

:::::::::::::::::::::::::::::::::

::start::::::::::

:start_

title auto_set_ip_v

if not exist "%datebase%" (call :error "缺少数据库文%datebase%")

::setp0--脚本功能介绍

cls

echo.

echo.

echo.

echo _________________________________________________________________

echo.

echo 根据mac自动修改ip地址、网关、dns、计算机名、工作组等

echo.

echo 使用前请先修%datebase%,建议使用excel来修改

echo 适合于只安装个物理网卡

echo 如果需要把数库放到本脚内修改变量datebase,建议看脚本26行左右注

echo.

echo by:vkill

echo _________________________________________________________________

set/p= 3秒后继

...

ping -n 4 127.1 >nul 2>nul

::##########################

:setp1

cls

echo 获取硬件信息(如系统刚启动待的时间要一些)...

wmic path win32_pnpsigneddriver >nul 2>nul || (

echo 执行wmic path win32_pnpsigneddriver发生错

echo 具体错误信息google baidu

echo 部分错误信息/?tid=83464

echo 错误信息如下

echo

_________________________________________________________________

echo c:^>wmic path win32_pnpsigneddriver

wmic path win32_pnpsigneddriver

echo

_________________________________________________________________

echo 任意键退出...

pause >nul 2>nul

exit /b

)

::得到已安装的理网卡型号

echo 获取网卡型号...

wmic path win32_pnpsigneddriver where "deviceclass='net' and compatid like

'%%%%'" get FriendlyName >"%temp%%t%_1" 2>nul

wmic path win32_pnpsigneddriver where "deviceclass='net' and compatid like

'%%%%'" get Description >"%temp%%t%_2" 2>nul

set n=0

for /f "tokens=*" %%a in ('type "%temp%%t%_2"') do (set/a n+=1 & set "a!n!=%%a")

set n=0

for /f "tokens=*" %%a in ('type "%temp%%t%_1"') do (set/a n+=1 & set "b!n!=%%a")

cd.>"%temp%%t%_4"

for /l %%? in (1,1,%n%) do (>>"%temp%%t%_4" echo !a%%?!,!b%%?!)

cd.>"%temp%%t%_5"

set n=0

for /f "skip=1 tokens=1-2 delims=," %%a in ('type "%temp%%t%_4"') do (

set/a n+=1 & set "!n!=%%b"

if defined !n! (set "dd=%%b") else (set "dd=%%a")

>>"%temp%%t%_5" echo !dd!

)

set n=0

for /f "tokens=*" %%? in ('type "%temp%%t%_5"') do (set /a n+=1 & set "d!n!=%%?")

if not defined d1 (call :error "获取物理网卡号失败,请确认你已经装好了物理

卡及已以及经正常驱动" & goto :eof)

if !n! GTR 1 (

:xz_nd

cls

echo.

echo.

echo.

echo

_________________________________________________________________

echo.

for /l %%? in (1,1,!n!) do (

echo %%? : !d%%?!

)

echo.

echo

_________________________________________________________________

set/p= 请输入你要设的网卡的序

set/p "v= "

for /l %%? in (1,1,!n!) do (if ^!v!==^%%? set "description=!d%%?!")

if not defined description goto :xz_nd

) else (set "description=!d1!")

:loop

if "*!description:~-1!"=="* " (set "description=!description:~0,-1!") else

(goto :loop_end)

goto :loop

:loop_end

::利用网卡型号得到网卡的mac addressindex

echo 获取网卡mac地址中...

nicconfig where "Description like '!Description!'" get index,MACAddress

2>nul |findstr ":" >"%temp%%t%_3"

findstr . "%temp%%t%_3" >nul 2>nul || (

nicconfig where "Description like '!Description! - 数据包计划程

微型端口'" get index,MACAddress 2>nul |findstr ":" >"%temp%%t%_3"

)

for /f "tokens=1-2 delims= " %%a in ('type "%temp%%t%_3"') do (set "index=%%a" &

set "mac_address=%%b")

if not defined mac_address (call :error "获取物理网卡!description! mac地址失"

& goto :eof)

::开始备份现有置到一文件

echo 正在备份当前ip信息...

start /wait /min wmic.exe /OUTPUT:"backup_!mac_address!.log" nicconfig where

"index='!index!'"

::##########################

:setp2

cls

type "%datebase%" | findstr /i /b "%mac_address%" >nul 2>nul ||(set

"mac_address=%mac_address::=-%")

::根据%database%来匹配mac address来得到需要置的ip

for /f "eol=; tokens=1-10 delims= " %%a in ('"type "%datebase%" | findstr /i /b

"%mac_address%" 2>nul"') do (

set "hostname=%%b"

set "workgroup=%%c"

set "enabledhcp=%%d"

set "addr=%%e"

set "mask0=%%f"

set "gateway=%%g"

set "dns_primary=%%h"

set "dns_second=%%i"

)

if not defined hostname (call :error "数据库中没有mac address : %mac_address%

请联系管理员" & goto :eof)

::如果mask置为标准,那么这里根据段来计算得mask

if "*%mask0%"=="*standard" (

if %addr% LEQ 128 (set "mask=255.0.0.0") else (

if %addr% LEQ 192 (set "mask=255.255.0.0") else (

if %addr% LEQ 223 (set "mask=255.255.255.0") else (

call :error "网段只可以设A类、B类、C" & goto :eof

)

)

)

) else (set "mask=%mask0%")

echo.

echo.

echo.

echo 准配置信息如

echo _________________________________________________________________

echo.

echo hostname : !hostname!

echo workgroup : !workgroup!

echo.

echo Description : !Description!

echo Physical Address : !mac_address!

echo Dhcp Enabled : !enabledhcp!

if "*!enabledhcp!"=="*0" (

echo IP Address : !addr!

echo Subnet Mask : !mask!

echo Default Gateway : !gateway!

echo DNS Servers : !dns_primary!

echo !dns_second!

)

echo.

echo _________________________________________________________________

echo.

set/p= y键确认开配置:

sc /? | findstr "32" >nul 2>nul || (exit /b)

::##########################

:setp3

cls

echo.

echo.

echo.

echo 开始配置各信

echo _________________________________________________________________

echo.

::enabledhcp1设置为动态ip,如为0就设置ip

set "error="

if "*%enabledhcp%"=="*1" (call :enabledhcp) else (call :disabledhcp)

if not "*!workgroup!"=="*none" (

set/p= 修改工作组中...

start /wait /min wmic /RECORD:"%temp%%t%_11" computersystem where

"name='%COMPUTERNAME%'" call joindomainorworkgroup "","","!workgroup!",1

type "%temp%%t%_11" | findstr /i "ReturnValue = 0;$" >nul 2>nul && (echo ok)

|| (echo no & set "error=error")

)

if not "*!hostname!"=="*none" (

set/p= 修改计算机名...

start /wait /min wmic /RECORD:"%temp%%t%_12" computersystem where

"name='%COMPUTERNAME%'" rename "!hostname!"

type "%temp%%t%_12" | findstr /i "ReturnValue = 0;$" >nul 2>nul && (echo ok)

|| (echo no & set "error=error")

)

echo _________________________________________________________________

echo.

if not defined error (

del /f/q/a "%temp%%t%_*" >nul 2>nul

echo 设置全部修改

ping -n 5 127.1 >nul 2>nul

) else (call :error "一些设置没有功,请检查" & goto :eof)

exit /b

goto :eof

::call:::::::::::::::::::::::::::::::

:error

for /l %%? in (1,1,10) do (echo %~1 &ping -n 3 127.1 >nul 2>nul)

exit /b

::

:enabledhcp

set/p= 设置为自动获...

start /wait /min wmic /RECORD:"%temp%%t%_13" path

Win32_NetworkAdapterConfigurati=!index! call enabledhcp

type "%temp%%t%_13" | findstr /i "ReturnValue = 0;$" >nul 2>nul && (echo ok) ||

(echo no & set "error=error")

goto :eof

::

:disabledhcp

set/p= 设置ip地址...

start /wait /min wmic /RECORD:"%temp%%t%_14" nicconfig where "index='!index!'"

call enablestatic "!addr!","!mask!"

type "%temp%%t%_14" | findstr /i "ReturnValue = 0;$" >nul 2>nul && (echo ok) ||

(echo no & set "error=error")

if not "*!gateway!"=="*none" (

set/p= 设置网关中...

start /wait /min wmic /RECORD:"%temp%%t%_15" nicconfig where

"index='!index!'" call setgateways "!gateway!",1

type "%temp%%t%_15" | findstr /i "ReturnValue = 0;$" >nul 2>nul && (echo ok)

|| (echo no & set "error=error")

)

if not "!dns_primary!"=="none" if "!dns_second!"=="none" (

set/p= 设置主dns...

start /wait /min wmic /RECORD:"%temp%%t%_16" nicconfig where

"index='!index!'" call setdnsdomain "'!dns_primary!'"

start /wait /min wmic /RECORD:"%temp%%t%_17" nicconfig where

"index='!index!'" call SetDNSServerSearchOrder "'!dns_primary!'"

type "%temp%%t%_17" | findstr /i "ReturnValue = 0;$" >nul 2>nul && (echo ok)

|| (echo no & set "error=error")

)

if "!dns_primary!"=="none" if not "!dns_second!"=="none" (

set/p= 设置辅dns...

start /wait /min wmic /RECORD:"%temp%%t%_16" nicconfig where

start /wait /min wmic /RECORD:"%temp%%t%_17" nicconfig where

"index='!index!'" call setdnsdomain "'!dns_second!'"

"index='!index!'" call SetDNSServerSearchOrder "'!dns_second!'"

type "%temp%%t%_17" | findstr /i "ReturnValue = 0;$" >nul 2>nul && (echo ok)

|| (echo no & set "error=error")

)

if not "!dns_primary!"=="none" if not "!dns_second!"=="none" (

set/p= 设置主辅dns...

start /wait /min wmic /RECORD:"%temp%%t%_16" nicconfig where

start /wait /min wmic /RECORD:"%temp%%t%_17" nicconfig where

call SetDNS"index='!index!'" ServerSearchOrder

"index='!index!'" call setdnsdomain ^("!dns_primary!","!dns_second!"^)

^("!dns_primary!","!dns_second!"^)

type "%temp%%t%_17" | findstr /i "ReturnValue = 0;$" >nul 2>nul && (echo ok)

|| (echo no & set "error=error")

)

goto :eof

::

学校机房

00-13-D3-3C-CB-27 ST01 workgroup 0 192.168.1.101 255.255.255.0 192.168.1.1

61.153.177.196 61.153.177.197

00-13-D3-3C-CD-F7 ST02 workgroup 0 192.168.1.102 255.255.255.0 192.168.1.1

61.153.177.196 61.153.177.197