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

Posted on 2011-10-23
Medium Priority
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 (http://wsusservername.com )


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

lciprianionut earned 1000 total points
ID: 37015082
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


Assisted Solution

Hobett earned 1000 total points
ID: 37015167
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


Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
Suggested Courses

850 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