Func _ChangName()
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$HostNameForm = GUICreate("", 443, 52, 294, 200)
$HostNameLabel = GUICtrlCreateLabel("计算机名称:", 20, 16, 76, 20)
$HostNameInput = GUICtrlCreateInput("请输入正确计算机名称", 116, 16, 209, 21)
$HostNameButton = GUICtrlCreateButton("确认", 344, 16, 75, 20)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $HostNameInput
Case $HostNameButton
If GUICtrlRead($HostNameInput) = '请输入正确计算机名称' Or GUICtrlRead($HostNameInput) = '' Then
TrayTip('提示', '请输入正确的计算机名称!', 1)
Else
$NameValue = GUICtrlRead($HostNameInput)
GUIDelete ( $HostNameForm )
RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName', 'ComputerName', 'REG_SZ', $NameValue)
RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName', 'ComputerName', 'REG_SZ', $NameValue)
RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\ComputerName\ComputerName', 'ComputerName', 'REG_SZ', $NameValue)
RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters', 'NV Hostname', 'REG_SZ', $NameValue)
RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters', 'Hostname', 'REG_SZ', $NameValue)
RegWrite('HKEY_USERS\S-1-5-18\Software\Microsoft\Windows\ShellNoRoam', '', 'REG_SZ', $NameValue)
RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ComputerName\ActiveComputerName', 'ComputerName', 'REG_SZ', $NameValue)
RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters', 'NV Hostname', 'REG_SZ', $NameValue)
RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters', 'Hostname', 'REG_SZ', $NameValue)
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon', 'DefaultDomainName', 'REG_SZ', $NameValue)
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon', 'AltDefaultDomainName', 'REG_SZ', $NameValue)
TrayTip('提示', '计算机名称更改为' & $NameValue & '成功!', 3)
EndIf
EndSwitch
WEnd
EndFunc ;==>_ChangName