找回密码
 加入
搜索
查看: 1708|回复: 3

用objWMIService改不了计算机名,请大家帮忙看看

[复制链接]
发表于 2009-11-9 13:06:32 | 显示全部楼层 |阅读模式
Func _SetComputerName($_computername)

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = TRUE", "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
$colComputers = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem")      
            
For $objNetAdapter in $colComputers
     $objNetAdapter.Rename($_computername)
Next
EndFunc
 楼主| 发表于 2009-11-9 13:07:30 | 显示全部楼层
$_computername这个是绝对可以取得到值的如Y0031
发表于 2010-2-15 12:45:30 | 显示全部楼层
俺是调用dos命令
RunWait(@COMSPEC & " /c wmic useraccount where name='新计算机名' call rename name=旧计算机名")
发表于 2010-2-15 13:00:59 | 显示全部楼层
用API
$_ComputerName="MyComputer"
$_Return=DllCall("Kernel32.dll","int","SetComputerNameEx","int",5,"str",$_ComputerName)
If $_Return[0]<>0 Then  MsgBox(0,"","修改成功,重启后生效!")
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-11-16 22:47 , Processed in 0.072215 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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