Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript Error 424

Status
Not open for further replies.

jose789

IS-IT--Management
Jun 26, 2003
1
US
Hi, I have created a script to update the SNMP Location in each server. The script reads the servers from a text file, then connect to each one and update the location through the registry. The script works very well on Windows 2003 servers, but I can't get it to work on Windows 2000 Servers. Thanks in advanced!!!

This is the one that works very well in Windows 2003.
On Error Resume Next

Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("\\pl1web01\NTSG\Windows_Utilities\SNMP_Change\PR01\servers.txt", ForReading)

Do Until objTextFile.AtEndOfStream
strComputer = objTextFile.ReadLine


Const HKEY_LOCAL_MACHINE = &H80000002

Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&_
strComputer & "\root\default:StdRegProv")

strKeyPath = "SYSTEM\CurrentControlSet\Services\SNMP\Parameters\RFC1156Agent\"
strValueName = "sysLocation"
strValue = "PR1/PC02/2"


strKeyPath = "SYSTEM\ControlSet001\Services\SNMP\Parameters\RFC1156Agent\"
strValueName = "sysLocation"
strValue = "PR1/PC02/2"

strKeyPath = "SYSTEM\ControlSet002\Services\SNMP\Parameters\RFC1156Agent\"
strValueName = "sysLocation"
strValue = "PR1/PC02/2"


Return = objReg.SetStringValue( _
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue)
If (Return = 0) And (Err.Number = 0) Then
Wscript.Echo strKeyPath & _
strValue
Else
Wscript.Echo "SetStringValue failed. Error = " & Err.Number
End If

Loop

objTextFile.Close
 
Verify that remote registry service and WMI are running on those boxes and verify that the Windows Firewall is not blocking either.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top