用objWMIService改不了计算机名,请大家帮忙看看
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 $_computername这个是绝对可以取得到值的如Y0031 俺是调用dos命令
RunWait(@COMSPEC & " /c wmic useraccount where name='新计算机名' call rename name=旧计算机名") 用API$_ComputerName="MyComputer"
$_Return=DllCall("Kernel32.dll","int","SetComputerNameEx","int",5,"str",$_ComputerName)
If $_Return<>0 ThenMsgBox(0,"","修改成功,重启后生效!")
页:
[1]