troubleshooting Question

batch script to download patches & silent install

Avatar of sunhux
sunhux asked on
Windows BatchVB ScriptScripting Languages
5 Comments2 Solutions28 ViewsLast Modified:
I'll need a Windows .bat script (not a PowerShell script).
This batch script could call powershell.exe though as
shown below the ===  lines.

Lately with most staff working from home, patchings from
WSUS (somehow our WSUS often has instability issues
that our Wintel guys just can't fix it despite reinstalling) &
possibly WSUS can't push patches down via VPN to our
staffs' laptops (heard SCCM can't push patches via VPN).

Plan to run the script daily under local admin's Task Scheduler
so if the script find that current patches on the PC is already
up-to-date, it won't pull down/install the patches.  If can
make this script run as service/background, will be better.

Script further below (extracted from spiceworks) is close to what I need:
https://community.spiceworks.com/topic/1951749-script-to-install-patches
just that I need help to enhance it such that it'll check between what're
the patches missing in the laptop vs what's available in MS:

Will also need to make the script as a service that runs under local
admin to regularly check for connectivity to Internet (we use split
VPN tunnel, such that only proxy-aware apps such as browsers
& Outlook will hv to take the route back to office corporate network
while I presume 'wusa' tool is not proxy-aware app.

This is a supplementary method to our WSUS : our Wintel guys run
into issue getting WSUS to patch for 6-12 months so I'll need an
alternative.  We don't have SCCM but have Desktop Central.

===================================

@echo off
cd/
echo "Downloading Patches; This will take several minutes depends on your Internet speed"
powershell -Command "(New-Object Net.WebClient).DownloadFile('http://download.windowsupdate.com/c/msdownload/update/software/uprl/2020/03/windows-kb000000-x64-v5.81_74132082f1421c2217b1b07673b671ceddba20fb.exe', ' kb000000_Scan.exe')"
echo "1 out of 4 downloaded"
echo "****"
powershell -Command "(New-Object Net.WebClient).DownloadFile('http://download.windowsupdate.com/c/msdownload/update/software/secu/2020/03/windows10.0- kb000000-x64_5db6cfc57a8bda4d13107ad24b3fe8fd790219cf.msu', ' kb000000.msu')"
echo "2 out of 4 downloaded"
echo "****"
powershell -Command "(New-Object Net.WebClient).DownloadFile('http://download.windowsupdate.com/c/msdownload/update/software/secu/2020/04/windows10.0- kb000000-x64_705fda69935538eab5054d9d616e1761742816ec.msu', ' kb000000.msu')"
echo "3 out of 4 downloaded"
echo "****"
powershell -Command "(New-Object Net.WebClient).DownloadFile('http://download.windowsupdate.com/d/msdownload/update/software/secu/2020/04/windows10.0- kb000000-x64_5411f88ea08bfc0ac98f388f5a3bdc8bcfea3261.msu', ' kb000000.msu')"
echo "4 out of 4 are downloaded, Now installing patches!"
echo "****"
@echo off
cd/
wusa.exe C:\ kb000000.msu /quiet /norestart
echo " kb000000 is installed, processing the next one"
echo "****"
wusa.exe C:\ kb000000.msu /quiet /norestart
echo " kb000000 is installed, processing the next one"
echo "****"
echo "This will take 5-10 mins for installing"
echo "****"
wusa.exe C:\ kb000000.msu /quiet /norestart

===================================

I presume the script above hardcode specific patch/
update but would need to make it generic : we don't
have anymore Win7 nor Win 8 but various builds of
Windows 10.

Script will need to patch Windows, MS Office (incl
Outlook), MS Edge & Chrome.

ASKER CERTIFIED SOLUTION
Seth Simmons
Lead Systems Administrator
Join our community to see this answer!
Unlock 2 Answers and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros