Windows Update Agent force script, email results version 2.3 by — Rob Dunn [WSUS MVP]

Rob Dunn [WSUS MVP] has created an excellent .vbs script (updatehf.vbs) which is very popular in WSUS Community. This script will do the following;

  1. Detects missing updates,
  2. Downloads approved updates which are missing,
  3. Installs the approved updates from WSUS Server,
  4. And reboots the computer after the updates are applied.
  5. Last but not the least; it can email a recipient the resulting log file.

Before you run this script, rename the downloaded script to updatehf.vbs and you need to edit some variables in the script;


  1. sExePath – this is the location of the WindowsUpdateAgent20-x86.exe. Download it from This script will install WindowsUpdateAgent20-x86.exe silently if it is required.
  2. strMailFrom – this is the email address used by the script to send the resulting log file to the intended recipient. (The Sender)
  3. strMailto – this is the recipient email address who will receive the resulting log file (The Recipient)
  4. strSMTPServer – this is the IP Address of the email server.


  1. Silent – 0 = verbose, 1 = silent (no windows or visible information)
  2. Intdebug – 0 = off, 1 = 1 (see some variables that are being passed)
  3. strAction – prompt|install|detect. Prompt gives users opportunity to install updates or not, install just installs them, detect updates the WU collection and downloads the updates (but does not install them) – useful if you want to have the computer refresh its stats to the stat server but not install the updates.
  4. blnEmail – 0 = off|1 = on. If set to 0, the script will not email a log file. If you specify an email address in the command-line, this will force the script to switch blnEmail to 1.
  5. strRestart – 0 = Do nothing|1 = restart|2 = shutdown. Command-switch restart: supersedes this variable.

If you don’t configure these optional variables, then you can manually input them from the command line.

Command line switches to run the script

  1. action: prompt|install|detect
  2. mode: silent|verbose
  3. email:
  4. restart: 0 (do nothing)| 1 (restart) | 2 (shutdown)
  5. force: 0 (do not enforce restart action – this is optional, by default it is set to 0) | 1 (enforce restart action)
  6. emailsubject: Text for custom subject enclosed in quotations (i.e. “This is a custom subject”) – (v2.2 and newer)
  7. fulldnsname: 0 (use non-qualified server name) | 1 (use fully qualified DNS name of the server that the script ran on) – (v2.2 and newer)
  8. emailifallok: 0 (don’t email a report if there are no problems with the update process) | 1 (email report whether there are errors or not) – (v2.2 and newer)
  9. smtpserver: x.x.x.x or smtp mail hostname (define an alternate SMTP server) – (v2.2 and newer)
  10. logfile:“x:\path\log.txt” – (v2.3 and newer)


The command line switches will supersede the variables in the script.


  1. DETECT (interactive): updatehf.vbs action:detect mode:verbose restart:0
  2. INSTALL (silently): updatehf.vbs action:install mode:silent restart:1
  3. PROMPT: updatehf.vbs action:prompt mode:verbose restart:1

Kudos to Rob and all those who have contributed. Once again thanks a lot Rob.

DOWNLOAD the latest version from (current version 2.3)

See the changelog

If you have any issues/comments/bugs/suggestions or just want to say thanks to Rob, then reply to the on-going discussion on Windows Update Agent force script, email results version 2.3

Leave a Reply

Your email address will not be published. Required fields are marked *