|
Something wrong must be on arrays of kix.Or something wrong with my mind.Whatever here are one windows scripting host script i found (seems to be correct)
sNameSpace = "root/CIMV2" sTargetClass = "Win32_NetworkAdapterConfiguration" sClass = "Win32_NetworkAdapter" sProperty1 = "AdapterType" sValue1 = "Ethernet 802.3" sProperty2 = "NetConnectionStatus" iValue2 = 2
sComputer = "SWYNKPC0001" sPriWINS = "1.2.3.4" sSecWINS = "1.2.4.3" aDNSServers = Array("1.2.2.1","1.2.3.5") sDNSDomain = "swynk.com" iNetBIOS = 1
sWQLQuery = "SELECT * FROM " & sClass & " WHERE " & sProperty1 & "=" & Chr(34) & sValue1 & Chr(34) & _ " AND " & sProperty2 & "=" & iValue2
Set cInstances = GetObject("winmgmts:{impersonationLevel=impersonate}//" & _ sComputer & "/" & sNameSpace).ExecQuery(sWQLQuery, "WQL")
For Each oInstance In cInstances Set cAssociators = oInstance.Associators_(,sTargetClass) For Each oAssociator In cAssociators Set oMethod = oAssociator.Methods_("SetWINSServer") Set oInParam = oMethod.InParameters.SpawnInstance_() oInParam.WINSPrimaryServer = sPriWINS oInParam.WINSSecondaryServer = sSecWINS Set oOutParam = oAssociator.ExecMethod_("SetWINSServer", oInParam)
If oOutParam.returnValue = 0 Then WScript.Echo UCase("SetWINSServer") & " method completed successfully" Else WScript.Echo UCase("SetWINSServer") & " method failed. Error Number " & oOutParam.returnValue End If
Set oMethod = oAssociator.Methods_("SetDNSServerSearchOrder") Set oInParam = oMethod.InParameters.SpawnInstance_() oInParam.DNSServerSearchOrder = aDNSServers Set oOutParam = oAssociator.ExecMethod_("SetDNSServerSearchOrder", oInParam)
If oOutParam.returnValue = 0 Then WScript.Echo UCase("SetDNSServerSearchOrder") & " method completed successfully" Else WScript.Echo UCase("SetDNSServerSearchOrder") & " method failed. Error Number " & oOutParam.returnValue End If
Set oMethod = oAssociator.Methods_("SetDNSDomain") Set oInParam = oMethod.InParameters.SpawnInstance_() oInParam.DNSDomain = sDNSDomain Set oOutParam = oAssociator.ExecMethod_("SetDNSDomain", oInParam)
If oOutParam.returnValue = 0 Then WScript.Echo UCase("SetDNSDomain") & " method completed successfully" Else WScript.Echo UCase("SetDNSDomain") & " method failed. Error Number " & oOutParam.returnValue End If
Set oMethod = oAssociator.Methods_("SetTCPIPNetBIOS") Set oInParam = oMethod.InParameters.SpawnInstance_() oInParam.TcpipNetBIOSOptions = iNetBIOS Set oOutParam = oAssociator.ExecMethod_("SetTCPIPNetBIOS", oInParam)
If oOutParam.returnValue = 0 Then WScript.Echo UCase("SetTCPIPNetBIOS") & " method completed successfully" Else WScript.Echo UCase("SetTCPIPNetBIOS") & " method failed. Error Number " & oOutParam.returnValue End If
Next Next
(http://www.serverwatch.com/tutorials/article.php/1556311)
y can not do the same with kix???????????
|