Avatar of erwin_miranda
erwin_miranda

asked on 

Can Some one Please Help with NTP Server Reg VBS

Can someone tell me why this code is not working
I am trying to implemented to the domain early tommorow
the error that i am getting is
Line 61
Char 1
Error: Object required: 'www'
Code 800A01a8

'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 2009
'
' NAME:
'
' AUTHOR: Erwin , Miranda Corp
' DATE  : 2/28/2009
'
' COMMENT: Modifying a Registry Entry
'
'=========================================================================

strServiceName = "W32Time"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery("Select * from Win32_Service Where Name ='" & strServiceName & "'")
For Each objService in colListOfServices
    objService.StopService()
Next

Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForReading = 1
strInputFile = "C:\Users\Erwin\Desktop\Scripts1\Mod_Registry\ALL_COMPUTERS.txt"
Set objInputFile = objFSO.OpenTextFile(strInputFile, intForReading, False)
While Not objInputFile.AtEndOfStream
      strComputer = objInputFile.ReadLine
      If Ping(strComputer) = True Then
            On Error Resume Next
            Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_  
                  strComputer & "\root\default:StdRegProv")
            If Err.Number = 0 Then
                  On Error GoTo 0
                  objReg.SetDWORDValue constHKEY_LOCAL_MACHINE, strKeyPath & strDWORDValueName, strDWORDValue      
                  WScript.Echo strDWORDValueName & " was set to " & strDWORDValue
            Else
                  Err.Clear
                  On Error GoTo 0
                  WScript.Echo "There was an error connecting to the registry on " & strComputer
            End If
      Else
            WScript.Echo strComputer & " could not be pinged."
      End If
 Wend
 objInputFile.Close
 Set objInputFile = Nothing
 WScript.Echo "www.google.com"
 WScript.Echo "Done"
 
Function Ping(strComputer)
      Dim objShell, boolCode
      Set objShell = CreateObject("WScript.Shell")
      boolCode = objShell.Run("Ping -n 4 -w 300 " & strComputer, 0, True)
      If boolCode = 0 Then
            Ping = True
      Else
            Ping = False
      End If
End Function

Set objShell = WScript.CreateObject ("WScript.Shell")
arrValues = objShell.RegWrite_("HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Parameters\NtpServer", www.google.com , "REG_SZ")
    For Each srtValue In arrValues
    WScript.Echo starValue
Next

strServiceName = "W32Time"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery ("Select * from Win32_Service Where Name ='" & strServiceName & "'")
For Each objService in colListOfServices
    objService.StartService()
Next
 
Windows XP

Avatar of undefined
Last Comment
Don

8/22/2022 - Mon