The Pixel Wall

The Blog Of Dan

Script To Fix Windows Updates On Remote Machines

I have created a quick script that will fix Windows Update on remote machines. It will need to be saved as a .bat file and requires PSTOOLS.

If you have a machine that’s not picking up updates, or not reporting in correctly, or failing to install updates you can use this script. This can be due to corrupt content in the SoftwareDistribution Folder.

It’s designed to work with remote machines. It takes advantage of PSEXEC, so it will need to go in the same directory as the tool.

You enter the target machines name and it does the following:
Stops Windows Update Service
Deletes the SoftwareDistribution Folder
Starts Windows Update Service
Creates the SoftwareDistribution Folder
Force a Check in, Reset and Update download

:Start
cls
@echo off
Echo.
Echo Remote Windows Update Fix and Check
Echo.

Set /P Computer=Enter Remote Computer Name:
If  "%Computer%"==  "" goto Error
pause

sc \\%Computer% stop wuauserv
TIMEOUT /T 10

psexec \\%Computer% cmd /c rmdir c:\windows\SoftwareDistribution /S /Q

sc \\%Computer% start wuauserv
TIMEOUT /T 10

psexec \\%Computer% -s wuauclt /resetauthorization /detectnow
TIMEOUT /T 5
psexec \\%Computer% -s wuauclt /reportnow

Goto End

:Error
Cls
Echo.
Echo Incorrect Computer Name Entered
Echo Please enter a valid Computer Name.
Echo.
Pause
Goto Start

:End

 

 

, , , ,

Leave a Reply

Your email address will not be published.