原创,在封装的系统,安装过程,自动用0到32767之间的任意十进制数字设置计算机名称的方法

封装系统时,常常会考虑到计算机名的设置问题,那么如何在这个过程中自动用 0 到 32767 之间的任意十进制数字设置计算机名称呢?

可以将下内容复制后,另存为pcn.bat,为了方便使用可以放在Alluser的启动中,本批处理只运行一次,完成后自动删除.

@echo off

rem %RANDOM% 可以返回 0 到 32767 之间的任意十进制数字。
set name=Nzhe-%random%

echo +———————————————————-+
echo |快速设置计算机名-由Darwin提供http://www.nzhe.net         |
echo |计算机名的形式为Nzhe-加上0 到 32767 之间的随机数值        |
echo +———————————————————-+

echo wscript.sleep 3000>%tmp%\delay.vbs&&%tmp%\delay.vbs&&del /q %tmp%\delay.vbs

reg add “HKU\S-1-5-21-1844237615-1383384898-1957994488-500\Software\Microsoft\Windows Media\WMSDK\General” /v ComputerName /t reg_sz /d %name% /f

reg add “HKU\S-1-5-21-1844237615-1383384898-1957994488-500\Volatile Environment” /v LOGONSERVER /t reg_sz /d \\%name% /f

reg add “HKCU\Software\Microsoft\Windows Media\WMSDK\General” /v ComputerName /t reg_sz /d %name% /f

reg add “HKCU\Volatile Environment” /v LOGONSERVER /t reg_sz /d \\%name% /f

reg add “HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon” /v AltDefaultDomainName /t reg_sz /d %name% /f

reg add “HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon” /v DefaultDomainName /t reg_sz /d %name% /f

reg add “HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName” /v ComputerName /t reg_sz /d %name% /f

reg add “HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName” /v ComputerName /t reg_sz /d %name% /f

reg add “HKLM\SYSTEM\CurrentControlSet\Services\Eventlog” /v ComputerName /t reg_sz /d %name% /f

reg add “HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters” /v “NV Hostname” /t reg_sz /d %name% /f

reg add “HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters” /v Hostname /t reg_sz /d %name% /f

reg add “HKLM\SYSTEM\ControlSet001\Control\ComputerName\ComputerName” /v ComputerName /t reg_sz /d %name% /f

reg add “HKLM\SYSTEM\ControlSet001\Control\ComputerName\ActiveComputerName” /v ComputerName /t reg_sz /d %name% /f

reg add “HKLM\SYSTEM\ControlSet001\Services\Eventlog” /v ComputerName /t reg_sz /d %name% /f

reg add “HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters” /v “NV Hostname” /t reg_sz /d %name% /f

reg add “HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters” /v Hostname /t reg_sz /d %name% /f

reg add “HKLM\SYSTEM\ControlSet002\Control\ComputerName\ComputerName” /v ComputerName /t reg_sz /d %name% /f

reg add “HKLM\SYSTEM\ControlSet002\Services\Eventlog” /v ComputerName /t reg_sz /d %name% /f

reg add “HKLM\SYSTEM\ControlSet002\Services\Tcpip\Parameters” /v “NV Hostname” /t reg_sz /d %name% /f

reg add “HKLM\SYSTEM\ControlSet002\Services\Tcpip\Parameters” /v Hostname /t reg_sz /d %name% /f

echo +—————————————————————————+
echo |计算机名设置成功,正在清除临时文件,完成后自动退出,计算机名重启生效……      |
echo +—————————————————————————+
echo wscript.sleep 1000>%tmp%\delay.vbs&&%tmp%\delay.vbs&&del /q %tmp%\delay.vbs

del C:\Docume~1\AllUse~1\「开始~1\程序\启动\pcn.bat

Tags: , , ,

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • RSS

Leave a Reply

You must be logged in to post a comment.

文字链