请问如何修改机器名【已解决】
本帖最后由 qddoit 于 2015-5-13 01:37 编辑读取ini然后修改极其名称 _WMI_SetNetworkAdapterInfo 注册表修改方式,不用重启可以立即生效,cmd运行hostname验证即可!献丑了!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 DllCall("Kernel32.dll", "int", "SetComputerNameEx", "int", 5, "str", $Newname) 回复 4# lpxx
真简单... {:1_304:}谢谢啦 本帖最后由 邪恶海盗 于 2015-5-14 16:26 编辑
回复 4# lpxx 7282D7 00058720 SetComputerNameA
7292D8 00058838 SetComputerNameExA
7302D9 0005869F SetComputerNameExW
7312DA 00058579 SetComputerNameW 不对啊,我在网上找XP SP3 Kernel32.dll API,发现没有你的这个啊
页:
[1]