Jump to content

Batch script for windows & software updates installation


Recommended Posts

Hello to all,

Am no Computer guru nor Programmer Geek. Please please can anyone write me a batch script for installing win 7 updates manually from a folder i have on hard disk.This is what i want to be exact.

I have windows updates files i have been downloading from catalog.update.microsoft.com. in a folder on Drive D of my Laptop. now every time there is an update alert by windows 7 update agent, i go to catalog.update.microsoft.com and download the updates to my folder. This way i dont have to download the same updates when i want to update my PC desktop running widows 7.

So i humbly ask this great community to help me out to accomplish this by giving me a batch script which i can paste on Notepad and save it as a .bat file so when i double click my .bat file i will install my updates silently on the target system.

eg. AMD64-all-windows6.1-kb2482017-x64_95006a2b965e8566d8a57600a0c0c53cb7212874.msu

AMD64-all-windows6.1-kb2479628-x64_a774713ef62d45373a08d4a7c0acfa18e8ec87c8.msu

I want a batch script to find the msu's file in a folder and install them silently. It should install the the first update till finnish before installing the second one and so forth.

This is what i've been doing.

1. open cmd prompt and i type "DIR *.* /B >My folder name.bat (eg i have a folder for Apr 2011 updates named 12 Apr 11 Updates win 7) so i type "DIR *.* /B >12apr11upadteswin7.BAT" at the cmd prompt. This will give me all the file names of the msu's in a text file.

2. Then i manually replace .msu with .msu /quiet /norestart Eg. AMD64-all-windows6.1-kb2482017-x64_95006a2b965e8566d8a57600a0c0c53cb7212874.msu changes to AMD64-all-windows6.1-kb2482017-x64_95006a2b965e8566d8a57600a0c0c53cb7212874.msu /quiet /norestart

. i do this for all the msu files in that folder.

3. Then i add

@echo off

echo Installing 12 Apr 2011 Updates...... to be the first and second line of my batch file named 12apr11upadteswin7.BAT. so i have something like this at the end

@echo off
echo Installing 12 Apr 2011 Updates......
AMD64-all-windows6.1-kb2393802-x64_98de62e1afe597d60acb584552241477315bd33a.msu /quiet /norestart
AMD64-all-windows6.1-kb2425227-x64_0749e0e8531479e1de9347fe584e61d43c209c0f.msu /quiet /norestart
AMD64-all-windows6.1-kb2454826-v2-x64_1c0a9c5f9fa8a2ffebfc81c3163a46caf077838a.msu /quiet /norestart
AMD64-all-windows6.1-kb2467023-x64_7f10b8f14a55877cf2ee67cee41ab758c3a9b376.msu /quiet /norestart
AMD64-all-windows6.1-kb2475792-x64_2e8f675625883458482042e128f54167f0193f9b.msu /quiet /norestart
AMD64-all-windows6.1-kb2479628-x64_a774713ef62d45373a08d4a7c0acfa18e8ec87c8.msu /quiet /norestart
AMD64-all-windows6.1-kb2485376-x64_7082a10a94b6cfffdd28f5f57f02e15a5345f5a7.msu /quiet /norestart
AMD64-all-windows6.1-kb2487426-x64_248e8f34492d9ed52236150179313aaf29a544d4.msu /quiet /norestart
AMD64-all-windows6.1-kb2482017-x64_95006a2b965e8566d8a57600a0c0c53cb7212874.msu /quiet /norestart

Now i dont want to be finding .msu and replacing with .msu /quiet /norestart manually.

I want a script that will search my folder may be i have subfolders to seach in that too for msu's and install them one by one waiting to finnish installing the first update before installing the second one. i hope i have tried to explain myself clear

Your efforts to help this humble soul of mine will be highly appreciated

Edited by centi50
Link to comment
Share on other sites


I found this batch file, but I don't remember where. Tested and working!

But I don't know how to add timeout /t 3 (waiting after each update installed!)

Set the batch file inside the folder where you have all the updates you want install and launch the batch.

Updates.cmd


@echo off
for /f "skip=1" %%A in ('dir /b *.msu') do (
echo Installing Updates "%%A" ...
start /wait %%A /quiet /norestart > nul
)
echo.
echo ###########################################################
echo.
echo Updates installed
echo Press any key to restart
pause >NUL
shutdown -r -t 0

*Edit: the value "skip=1" is wrong and the first update will not be installed like explained by Yzöwl

Edited by myselfidem
Link to comment
Share on other sites

I've made some changes inside the batch file and works also fine like this for me, using wusa.exe:


@echo off
for /f %%A in ('dir /b *.msu') do (
echo == Installing Updates == "%%A" ...
timeout /t 3
C:\Windows\system32\wusa.exe %%A /quiet /norestart
)
echo.
echo ###########################################################
echo.
echo == Updates installed ==
echo.
echo == Press any key to restart ==&pause>nul
echo.
shutdown.exe /r /t 0

*Edit: post updated! Removed "skip=1" inside the batch file like explained by Yzöwl

Edited by myselfidem
Link to comment
Share on other sites

When your code does a directory listing of *.msu files, the first result, alphabetically by default, is deliberately being ignored and therefore not processed, (skip=1).

Additional note, please use correct English, not text speak, it helps our non English speakers to follow the conversations better.

Link to comment
Share on other sites

Yzowl. I dont know anything about batch programming. what i wanted was a batch file that can search my folders for .msu files and install them silently. Thanx to myselfidem he provided me the Batch code and it installed my msu's file. If you have a better Code. i'll be happy to employ it.

Link to comment
Share on other sites

That batch file you were provided with could not have installed all of your .msu files in that folder, silently or otherwise!

It skipped the first .msu file, because the code is wrong.

I've already told you why it skipped the first file, so just remove that request from the code and it will be instantly better.

Link to comment
Share on other sites

Many thanks Yzöwl

You're right. I haven't seen this before!

I've updated my last posts!

However, with this changes all updates .msu will be installed with the batch file inside the folder where are located all the updates, like you said.

(Removed "skip=1")


@echo off
for /f %%A in ('dir /b *.msu') do (
echo == Installing Updates == "%%A" ...
timeout /t 3
C:\Windows\system32\wusa.exe %%A /quiet /norestart
)
echo.
echo ########################################
echo.
echo == Updates installed ==
echo.
echo == Press any key to restart ==&pause>nul
echo.
shutdown.exe /r /t 0

For Windows 7 French localised version


@echo off
for /f %%A in ('dir /b *.msu') do (
echo == Installation des Mises … jour == "%%A" ...
timeout /t 3
C:\Windows\system32\wusa.exe %%A /quiet /norestart
)
echo.
echo ########################################
echo.
echo == Mises … jour install‚es ==
echo.
echo == Appuyez sur n'importe qu'elle touche pour red‚marrer ==&pause>nul
echo.
shutdown.exe /r /t 0

@centi50

Sorry, I haven't seen this error before!

*Edit: Output inside the command window

timeout /t 3 (means waiting 3 seconds between each update to install)

----------------------------------------------------------------------------------------------------------------

== Installation des Mises à jour == "Windows6.1-KB2425227-x86.msu" ...

Attendre 0 secondes, appuyez sur une touche pour continuer...

== Installation des Mises à jour == "Windows6.1-KB2479943-x86.msu" ...

Attendre 0 secondes, appuyez sur une touche pour continuer...

== Installation des Mises à jour == "Windows6.1-KB2491683-x86.msu" ...

Attendre 0 secondes, appuyez sur une touche pour continuer...

== Installation des Mises à jour == "Windows6.1-KB2503658-x86.msu" ...

Attendre 0 secondes, appuyez sur une touche pour continuer...

== Installation des Mises à jour == "Windows6.1-KB2506212-x86.msu" ...

Attendre 0 secondes, appuyez sur une touche pour continuer...

== Installation des Mises à jour == "Windows6.1-KB2506223-x86.msu" ...

Attendre 0 secondes, appuyez sur une touche pour continuer...

== Installation des Mises à jour == "Windows6.1-KB2507618-x86.msu" ...

Attendre 0 secondes, appuyez sur une touche pour continuer...

== Installation des Mises à jour == "Windows6.1-KB2508272-x86.msu" ...

Attendre 0 secondes, appuyez sur une touche pour continuer...

== Installation des Mises à jour == "Windows6.1-KB2508429-x86.msu" ...

Attendre 0 secondes, appuyez sur une touche pour continuer...

== Installation des Mises à jour == "Windows6.1-KB2509553-x86.msu" ...

Attendre 0 secondes, appuyez sur une touche pour continuer...

== Installation des Mises à jour == "Windows6.1-KB2511455-x86.msu" ...

Attendre 0 secondes, appuyez sur une touche pour continuer...

#######################################################

== Mises à jour installées ==

== Appuyez sur n'importe qu'elle touche pour redémarrer ==

----------------------------------------------------------------------------------------------------------------

Edited by myselfidem
Link to comment
Share on other sites

Big Up to mselfidem and Yzöwl for Helping out. As i said am no Computer Geek or Guru, so there was no way i was going to spot any error in any batch code. But thanks to Bro Yzöwl . And Thx to myselfidem. To help me. Two questions i have to my friends.

1.I see the start & wait cmd is not there. will the installation still wait for the first installation to finnish then go to the other one. or will it start the second installation even if the first did not finnish?

2. Will these script search into subfolders containing the .MSU files? if not, Can anyone modify the batch to make it search into subfolder and install the .MSU files.

Please if somebody will modify the batch code and post, i kindly ask him or her to post the full batch code and not only the modification, Becoz i will not understand. i'll just copy the batch and save it.

Once again i thank all who helped me.

Link to comment
Share on other sites

Since we have a member already providing you with scripted help, the following script is posted only as an example.

@ECHO OFF&SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
FOR /R %%# IN (*-KB*.MSU) DO (CALL :SUB %%~n#
ECHO= INSTALLING KB!_!&ECHO=WUSA "%%#" /QUIET /NORESTART)
PAUSE&GOTO :EOF
:SUB
SET "_=%*"
FOR /F "DELIMS=-" %%$ IN ("%_:*-KB=%") DO SET "_=%%$"

It does answer your second question but may not perform to your exact requirements.

Link to comment
Share on other sites

You can find help using:

Start | Run and write: cmd

Inside the command window, write (examples):

for /? >C:\for.txt

call /? >C:\call.txt

After you can read the help about this commands inside the text files.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...