How to enter wsus server name for windows server 2008  through vbscript??

Posted on 2011-10-23
Last Modified: 2016-02-13
Hi All,

We are manually installing MS patch for windows server 2008.

Is there any way to add WSUS server name through vbscript or any other way as it takes lots of time through group policy??

These are the below steps which we are doing MS Patch for windows server 2008.

1.GOTO RUN-->Start Type MMC
2.GOTO File-->Select Add or Remove Snap-ins.
3. In Add or Remove Snap-ins select Group Policy Object.
 1.png2.jpg4.Click on Finish
5.GOTO Computer Configuration\Administrative Templates\Windows Components\Windows Update, Double Click on Configure Automatic Updates
6.Select ENABLED, and in select “2 – Notify for download and notify for install”. Click OK
7.Double click on “Specify intranet Microsoft update service location”, Under OPTIONS enter the WSUS server name ( )


8.Click OK.
9.Once you have clicked on OK, POPUP can be seen for downloading or installing updates. Click on the POPUP and select INSTALL.
10.Also check  in the registry if it is pointing to the correct WSUS server HKML\Software\Policies\Software\Policies\Microsoft\Windows\WindowsUpdate
Else modify to point to the correct WSUS server

11.ELSE, Rt.Click on MY Computer, click on Properties and click on “WINDOWS Update”

Can anyone help me how to enter WSUS server name through vbscript without going Group policy??

Any assistance would be greatly appreciated.
Question by:jashir101
    LVL 13

    Accepted Solution

    Hi, Try next script, it does more things, you need to change to your case
    Change cstrSUSServerURL  to your WSUS server
    '/* Windows Script Host Script: SetWUSServerCN.vbs                                  */
    '/*                                                                                 */
    '/* Connects the Windows Update service of the current computer to the WSUS server  */
    '/* specified by the constant cstrSUSServerURL.                                     */
    Option Explicit
    Const cstrSUSServerURL = ""
    '/* Function: ConfigureWindowsUpdate                                                */
    '/*                                                                                 */
    '/* Configures the Windows Update service for connecting to the specified WSUS      */
    '/* server using the URL specified by the constant cstrSUSServerURL.                */
    Function ConfigureWindowsUpdate()
      Dim intReturn, objWSHShell
      '// enable error handling
      On Error Resume Next
      '// create a new instance of the shell object
      Set objWSHShell = WScript.CreateObject("WScript.Shell")
      '// enter the registry keys needed to connect to the SUS Server
      objWSHShell.RegWrite "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\WUServer", cstrSUSServerURL, "REG_SZ"
      objWSHShell.RegWrite "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\WUStatusServer", cstrSUSServerURL, "REG_SZ"
      '// enter the registry keys specifying the update method and options
      objWSHShell.RegWrite "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\NoAutoRebootWithLoggedOnUsers", 1, "REG_DWORD"
      objWSHShell.RegWrite "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\UseWUServer", 1, "REG_DWORD"
      objWSHShell.RegWrite "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\RescheduleWaitTime", 1, "REG_DWORD"
      objWSHShell.RegWrite "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\NoAutoUpdate", 0, "REG_DWORD"
      objWSHShell.RegWrite "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\AUOptions", 3, "REG_DWORD"
      '// enter the registry key for specifyig the day and time of day when service checks for updates
      objWSHShell.RegWrite "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\ScheduledInstallDay", 0, "REG_DWORD"
      objWSHShell.RegWrite "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\ScheduledInstallTime", 10, "REG_DWORD"
      '// check the overall return status
      If (Err.Number <> 0) Then
        '// an error occured while writing the registry keys, set the completion code to 
        '// error (and leave a respective message in the log file)
        intReturn = intError
        WScript.Echo "(E) Error writing the WUS client configuration entries to the registry (" & Err.Number & ", " & Err.Description & ")."
        '// the function succeeded, set the return status to success 
        intReturn = intSuccess
        WScript.Echo "(S) WUS client configuration successfully written to registry."
      End If
      '// release the resources allocated by the shell object
      Set objWSHShell = Nothing
      '// turn off error handling
      On Error GoTo 0
      '// and terminate the function by returning the respective completion code
      ConfigureWindowsUpdate = intReturn
    End Function
    '/* Main                                                                            */
    Dim intReturn
    '// set the initial return status to error
    intReturn = intError
    '// write a short not about the beginning of the script to the log file
    WScript.Echo "(I) Windows Update Service (WUS) configuration started with URL '" & cstrSUSServerURL & "'."
    '// enter the registry keys for connecting the windows update service via the WSUS server
    intReturn = ConfigureWindowsUpdate()
    '// in case the updated succeeded, restart the windows update service in order to activated the settings
    If (intReturn <> intSuccess) Then
      '// the configuration failed, terminate the function with error (derived from the previous function)
      WScript.Echo "(F) Windows Update Service (WUS) configuration failed, automatic updates will not work properly."
      '// the configuration has been successfuly, restart the service in order to activate the settings;
      '// stop the service
      intReturn = StopService ("Windows Update")
      '// and start it over again
      intReturn = (intReturn OR StartService ("Windows Update"))
      '// check if an error occured during the restart; in that case write a warning to the log
      If (intReturn <> intSuccess) Then
        '// at least one of the service functions failed; write a warning to the log
        WScript.Echo "(W) Restart of the 'Windows Update' service failed, please check the service status manually."
        '// the restart has been successfull
        WScript.Echo "(S) 'Windows Update' service sucessfully restarted."
      End If
      '// all the important functions succeeded, terminate the function with a success message
      WScript.Echo "(S) Windows Update Service (WUS) configuration terminated successfully."
    End If

    Open in new window

    LVL 3

    Assisted Solution

    To clarify your situation, you have a Windows 2008 Server and a number of clients. WSUS will automate the update process, allow yout to delay updates and provide reporting.

    The script above would set the WSUS server but not take into account SSL or a different port being used for WSUS.

    If you have a domain and WSUS setup on the the server, then you only need to setup a minimum of one Group Policy to configure clients to receive the WSUS server settings. WSUS is best used with Client Targeting, in which case you need more than one Group Policy to for each group of clients you want to target with different settings. E.g. Servers to not automatcially apply updates or restart, clients to apply updates at a certain time and restart.

    Why are you creating an MMC console for editing the Group Policy, why not use the Group Policy Management console?

    If you do not have a domain but have WSUS setup on the server and need to set the cleint you can do that simply with the following registry fragment that can be tattooed in to the registry which is not recommended by using a batch file with the following command:

    REGEDIT /S WSUS-Settings.reg


    Windows Registry Editor Version 5.00


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    I was supporting a handful of Windows 2008 (non-R2) 2 node clusters with shared quorum disks. Some had SQL 2008 installed and some were just a vendor application that we supported. For the purposes of this article it doesn’t really matter which so w…
    You might have come across a situation when you have Exchange 2013 server in two different sites (Production and DR). After adding the Database copy in ECP console it displays Database copy status unknown for the DR exchange server. Issue is strange…
    This tutorial will give a short introduction and overview of Backup Exec 2014 and the additional features that have been added over its predecessor Backup Exec 2012. As with Backup Exec 2012, the Backup Exec button in the upper left corner. From her…
    This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now