找回密码
 加入
搜索
查看: 3158|回复: 6

[系统综合] 请问如何修改机器名【已解决】

  [复制链接]
发表于 2015-5-12 03:37:42 | 显示全部楼层 |阅读模式
本帖最后由 qddoit 于 2015-5-13 01:37 编辑

读取ini然后修改极其名称
发表于 2015-5-12 08:18:06 | 显示全部楼层
_WMI_SetNetworkAdapterInfo
发表于 2015-5-12 12:47:32 | 显示全部楼层
注册表修改方式,不用重启可以立即生效,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
发表于 2015-5-12 14:35:08 | 显示全部楼层
DllCall("Kernel32.dll", "int", "SetComputerNameEx", "int", 5, "str", $Newname)
发表于 2015-5-12 19:14:30 | 显示全部楼层
回复 4# lpxx


    真简单...
 楼主| 发表于 2015-5-13 01:37:12 | 显示全部楼层
谢谢啦
发表于 2015-5-14 16:25:20 | 显示全部楼层
本帖最后由 邪恶海盗 于 2015-5-14 16:26 编辑

回复 4# lpxx
728  2D7 00058720 SetComputerNameA  
729  2D8 00058838 SetComputerNameExA  
730  2D9 0005869F SetComputerNameExW  
731  2DA 00058579 SetComputerNameW 
不对啊,我在网上找XP SP3 Kernel32.dll API,发现没有你的这个啊
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-28 18:23 , Processed in 0.078651 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表