Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
scripts
hosting
jscript
remote
scripting.wsh
scriptlets
vbscript
virus.discussion
  
 
date: Fri, 4 Jan 2008 05:09:04 -0800,    group: microsoft.public.scripting.wsh        back       


Error configuring DNS remote   
I have this script which should be able to add an ip-address on the DNS in a 
workstation, but i get this error : 

Error configuring DNS on xx.xx.xx.xx ( workstation IP )
Error code: 451

How can i solve this problem ?

The script is here:

Option Explicit
Dim strComputer, strNamespace, strReg, strUser, strPassword
Dim strKeyPath, strCurrentPath
Dim RegKey1, RegKey2, RegKey3
Dim WSHShell, objWbemLocator, objWMIService, objArgs, objReg
Dim colNetCards, objNetCard, arrDNSServers, arrSubkeys, objSubkey
Dim objFSO, objStream

Const WbemAuthenticationLevelPktPrivacy = 6	'### Make sure password is 
encrypted on the network
const HKEY_USERS = &H80000003
Const ForReading = 1, ForWriting = 2, ForAppending = 8

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
If objArgs.Count = 0 Then
	WScript.Echo "Please provide client IP or Name as argument, example:" & 
vbCrLf & _
		"CScript GJChange.vbs 192.168.1.32" & vbCrLf & "or" & vbCrLf & _
		"CScript GJChange.vbs CLIENTPC04"
	WScript.Quit
End If

strComputer = objArgs(0)
strNamespace = "root\cimv2"
strReg = "root\default"
strUser = "user"
strPassword = "password"

Set WSHShell = CreateObject("WScript.Shell")
Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
strCurrentPath = WSHShell.CurrentDirectory

ConfigDNSProxy

'##########################
'### Functions and Subs ###
'##########################

'### Configure DNS and Proxy on Remote System
Sub ConfigDNSProxy
	On Error Resume Next
	WScript.Echo vbCrLf & "Connecting to computer: " & strComputer & "....."
	'### Configure DNS Settings
	Set objWMIService = objwbemLocator.ConnectServer _
		(strComputer, strNamespace, strUser, strPassword)
	objWMIService.Security_.authenticationLevel = 
WbemAuthenticationLevelPktPrivacy
	Set colNetCards = objWMIService.ExecQuery _
		("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
	For Each objNetCard in colNetCards
		arrDNSServers = Array("xxx.xxx.xxx.xxx")
		objNetCard.SetDNSServerSearchOrder(arrDNSServers)
	Next
	If Err.Number = 0 Then
		WScript.Echo "Succesfully configured DNS on " & strComputer
	Else
		WScript.Echo "Error configuring DNS on " & strComputer
		WScript.Echo "Error Code: " & Err.Number
		WScript.Echo "Error Description: " & Err.Message
		While Err.Number <> 0
			Err.Clear
			Randomize
			WScript.Sleep Rnd * 2000
			Set objStream = objFSO.OpenTextFile(strCurrentPath  & 
"\ComputersFailed.txt", ForAppending, TRUE)
			objStream.WriteLine strComputer
			objStream.Close
		Wend
		WScript.Quit
	End If

	Set objStream = objFSO.OpenTextFile(strCurrentPath  & "\ComputersDone.txt", 
ForAppending, TRUE)
	objStream.WriteLine strComputer
	objStream.Close
End Sub
date: Fri, 4 Jan 2008 05:09:04 -0800   author:   Georgebaker

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us