快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

使用脚本更改计算机名

第一种:

网站建设哪家好,找创新互联!专注于网页设计、网站建设、微信开发、成都小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了老城免费建站欢迎大家使用!

使用脚本更改计算机名

 

 

Dim reval
Set objnet = CreateObject ("WScript.Network")
Set R = CreateObject("WScript.Shell")
reval = InputBox ("当前的计算机名是:" & objnet.ComputerName,"输入新的计算机名")
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colComputers = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")

For Each objComputer in colComputers
err = objComputer.Rename(objnet.ComputerName)
Next

For Each objComputer in colComputers
errReturn = ObjComputer.Rename (reval)
If reval <> "" Then
                return=MsgBox ("你确定要重起计算机吗?",vbokcancel+vbexclamation,"注意!")
                If return=vbok Then
                        R.run("Shutdown.exe -r -t 0")
                End if
    End If
Next

第二种:自动改成该电脑的序列号

 

'Rename computer by serial # v1.0 November 2009
dim Bios, BiosSerial, objFSO, objTextFile
'Const ForReading = 1, ForWriting = 2, ForAppending = 8

'get serial number
for each Bios in GetObject("winmgmts:").InstancesOf ("win32_bios")
BiosSerial = Bios.SerialNumber
exit for
next

Set WshNetwork = WScript.CreateObject("WScript.Network")

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colComputers = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")

For Each objComputer in colComputers
err = objComputer.Rename(BiosSerial)
Next

'messagebox
msgbox "Computername changed to " + BiosSerial + "...", yes

 

 

第三种:改成自己设置的前缀名+时间

 

@echo off
mode con cols=45 lines=8
title 计算机名更改
color f8
set f=%time:~3,-6%
set m=%time:~6,-3%
echo.
echo.
echo.
set /p name=  前缀名:
echo.
echo.
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam" /v @ /t REG_SZ /d "%name%%f%%m%" /f >nul && reg add "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName" /v "ComputerName" /t REG_SZ /d "%name%%f%%m%" /f >nul && reg add "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName" /v "ComputerName" /t REG_SZ /d "%name%%f%%m%" /f >nul && reg add "HKLM\SYSTEM\CurrentControlSet\Services\Eventlog" /v "ComputerName" /t REG_SZ /d "%name%%f%%m%" /f >nul && reg add "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName" /v "ComputerName" /t REG_SZ /d "%name%%f%%m%" /f >nul && reg add "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" /v "NV Hostname" /t REG_SZ /d "%name%%f%%m%" /f >nul && reg add "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" /v "Hostname" /t REG_SZ /d "%name%%f%%m%" /f >nul
IF %ERRORLEVEL%==0 goto t
goto n
:t
echo.
echo.
echo.
echo  修改成功,要使更改生效,必须重新启动计算机.
echo.
echo.
echo.
pause
mode con cols=45 lines=8
title 系统设置改变
echo.
echo.
echo   必须重新启动计算机才能使新的设置生效。
echo.
echo   想现在就重新启动计算机吗?
echo.
echo   Y:确定   N:取消
echo.
set /p select1=请输入:
if /i "%select1%"=="Y" goto y
if /i "%select1%"=="N" goto n
:y
shutdown -r -t 0
exit
:n
exit


新闻标题:使用脚本更改计算机名
链接分享:http://6mz.cn/article/psshce.html

其他资讯