当前位置: 移动技术网 > IT编程>网络>Dos/Bat > 用批处理程序修改 计算机名 工作组 计算机描述的代码

用批处理程序修改 计算机名 工作组 计算机描述的代码

2017年12月08日  | 移动技术网IT编程  | 我要评论

wwe2014年6月24日,罗永浩吉林大学演讲,吉林化工学院教务管理系统

复制代码 代码如下:

@echo off
echo 骏龙包装计算机名称、计算机描述、工作组修改批处理程序
echo
pause
cls
:set/p id=请输入本机网段号:
:set/p ip=请输入本机ip地址:
:netsh interface ip set address name="本地连接" source=static addr=192.168.%id%.%ip% mask=255.255.255.0
set /p name=请输您的主机出厂s/n编号:
reg add "hkey_local_machine\system\currentcontrolset\control\computername\activecomputername" /v computername /t reg_sz /d %name% /f
reg add "hkey_local_machine\system\currentcontrolset\services\tcpip\parameters" /v "nv hostname" /t reg_sz /d %name% /f
reg add "hkey_local_machine\system\currentcontrolset\services\tcpip\parameters" /v hostname /t reg_sz /d %name% /f
set work=骏龙
wmic computersystem where name="%name%" call joindomainorworkgroup name="%work%"
set /p describe=请输入您的计算机描述(公司规定必须是使用者姓名):
reg add "hkey_local_machine\system\currentcontrolset\services\lanmanserver\parameters" /v srvcomment /t reg_sz /d %describe% /f

net config server /srvcomment:"%describe%"
pause

用批处理修改计算机名和工作组,不用重启!

如果你喜欢用ghost镜像的系统,那么每次重装完成之后的计算机名都是一串长长的随机字符,非常不方便和不美观。
一般来说,你在系统属性那里修改计算机名或者工作组,总是要进行重新启动,非常麻烦。甚至在最新的vista操作系统里面也是这样。
其实计算机名是保存在注册表里面的,我们可以通过直接修改注册表,达到修改的目的。

复制代码 代码如下:

hkey_local_machine\system\currentcontrolset\control\computername\activecomputername
hkey_local_machine\system\currentcontrolset\services\tcpip\parameters

工作组的修改可以通过一个wmic命令来实现目的。

wmic computersystem where name="%computername%" call joindomainorworkgroup name="%workgroup%"
现在我们把它写成一个批处理,来实现无需重启修改计算机名和工作组:

复制代码 代码如下:

@echo off
echo applife.net
set /p name=请输您的计算机名:
reg add "hkey_local_machine\system\currentcontrolset\control\computername\activecomputername" /v computername /t reg_sz /d %name% /f >nul 2>nul
reg add "hkey_local_machine\system\currentcontrolset\services\tcpip\parameters" /v "nv hostname" /t reg_sz /d %name% /f >nul 2>nul
reg add "hkey_local_machine\system\currentcontrolset\services\tcpip\parameters" /v hostname /t reg_sz /d %name% /f >nul 2>nul
echo.
echo 修改计算机名完毕
echo.
echo applife.net
set /p work1=请输入您的工作组名:
wmic computersystem where name="%computername%" call joindomainorworkgroup name="%work1%"
echo 修改工作组完毕
pause>nul
echo.

把上面的代码保存为一个bat文件,运行就可以了。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网