- set pcname=%TEMP%\pcname.txt
- echo sNewName = ComputerName >%pcname%
- echo sNewName="计算机名" >>%pcname%
-
- echo Set oShell = CreateObject ("WSCript.shell") >>%pcname%
-
- echo sCCS = "HKLM\SYSTEM\CurrentControlSet\" >>%pcname%
- echo sTcpipParamsRegPath = sCCS & "Services\Tcpip\Parameters\" >>%pcname%
- echo sCompNameRegPath = sCCS & "Control\ComputerName\" >>%pcname%
-
- echo With oShell >>%pcname%
- echo .RegDelete sTcpipParamsRegPath & "Hostname" >>%pcname%
- echo .RegDelete sTcpipParamsRegPath & "NV Hostname" >>%pcname%
-
- echo .RegWrite sCompNameRegPath & "ComputerName\ComputerName", sNewName >>%pcname%
- echo .RegWrite sCompNameRegPath & "ActiveComputerName\ComputerName", sNewName >>%pcname%
- echo .RegWrite sTcpipParamsRegPath & "Hostname", sNewName >>%pcname%
- echo .RegWrite sTcpipParamsRegPath & "NV Hostname", sNewName >>%pcname%
- echo End With >>%pcname%
- echo Msgbox "计算机名修改成功!"& vbcr &"重新启动计算机后生效!" >>%pcname%
复制代码
需更改的地方 echo sNewName="计算机名" >>%pcname%
“在批处理窗口输入我想更改的计算机名”如:“客户端1”echo出来的结果是: sNewName="客户端1" |