submix8c Posted March 16, 2013 Posted March 16, 2013 (edited) HOLEY KROWS!!!Sorry to bump this but SILLY ME went nutz trying to figure out why files/paths weren't being found!HERE is the reason - I had a "!" (exclamation point) as part of a Folder Name! DO NOT DO THIS sinceSET ENABLEDELAYEDEXPANSIONspecifically EXPECTS to use that as a Variable Delimiter, same case as CMD.EXE "/V:ON".Do NOT use that anywhere in any Pathname/Filename. (wasted time via experimentation...)HTH some poor idee-yut that does the same thing. Edited March 16, 2013 by submix8c 1
gohnick Posted April 10, 2013 Posted April 10, 2013 (edited) For windows xp updates, you can probably get away with simply changing MSU to EXE and removing WUSA.@ECHO OFF SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION FOR /R "%~dp0" %%A IN (*-KB*.EXE) DO ( CALL :SUB %%~nA ECHO= Installing KB!KB_NUM! >NUL PING -n 4 127.0.0.1 "%%A" /quiet /norestart) ECHO= == Press any key to restart == >NUL PAUSE SHUTDOWN.EXE /r /t 0 GOTO :EOF :SUB SET "KB_NUM=%*" FOR /F "DELIMS=-" %%B IN ("%KB_NUM:*-KB=%") DO SET "KB_NUM=%%B"Dear sir,Is it possible to include a string to output the installed KB numbers into a text file within the directory? Pardon my newbie question as I am a newbie in scripting Edited April 10, 2013 by gohnick
submix8c Posted April 10, 2013 Posted April 10, 2013 I won't swear to this, but puttingECHO= == List of KB's installed == >KBLIST.TXTright after the "SETLOCAL" and then placing ECHO= Installing KB!KB_NUM! >>KBLIST.TXT after the other one should do it.
gohnick Posted April 11, 2013 Posted April 11, 2013 I won't swear to this, but puttingECHO= == List of KB's installed == >KBLIST.TXTright after the "SETLOCAL" and then placing ECHO= Installing KB!KB_NUM! >>KBLIST.TXT after the other one should do it. Hi submix8c,Thanks for the tip! it works!
agnimitra1980 Posted May 20, 2013 Posted May 20, 2013 Hi using this script is it possible to capture status of each installation? like if there is any update which fails or does not apply, is there any way we can capture that?
centi50 Posted May 20, 2013 Author Posted May 20, 2013 Hello to AllI use the following code Batch script to Install the updates in a folder in my Win 7 x64 laptop.@ECHO OFFSETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSIONFOR /R "%~dp0" %%A IN (*-KB*.MSU) DO (CALL :SUB %%~nAECHO= Installing KB!KB_NUM!>NUL TIMEOUT /t 3WUSA "%%A" /quiet /norestart)ECHO= == Press any key to restart ==>NUL PAUSESHUTDOWN.EXE /r /t 0GOTO :EOF:SUBSET "KB_NUM=%*"FOR /F "DELIMS=-" %%B IN ("%KB_NUM:*-KB=%") DO SET "KB_NUM=%%B"The above code will Install all updates of .MSU located in a folder same as the batch script one after the other. What it won't do is, it won't install updates of .EXE e.g .NetFramework 4 updates and also it won't install Silverlight Updates.Please can some one Kindly re edit the above script for me to include the installation of .EXE files and Silverlight updates.Also note am totally zero in scripting, so kindly if changes are made please reproduce the above script with changes so i can copy and paste it in my .BAT file.Also note the code is not mine. i just got it in this thread, as i am the thread starter.Thanking all in advance for their time and efforts to Help out people like me.
Pikachu Posted December 23, 2013 Posted December 23, 2013 @ECHO OFFSETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSIONPUSHD %~dp0FOR %%A IN (*-KB*.MSU) DO ( CALL :SUB %%~nA ECHO= Installing KB!KB_NUM! >NUL TIMEOUT /t 3 WUSA "%%~fA" /quiet /norestart)ECHO= == Press any key to restart ==>NUL PAUSESHUTDOWN.EXE /r /t 0GOTO :EOF:SUBSET "KB_NUM=%*"FOR /F "DELIMS=-" %%B IN ("%KB_NUM:*-KB=%") DO SET "KB_NUM=%%B"So this is the script I should use? What about the exe files?
Yzöwl Posted December 23, 2013 Posted December 23, 2013 @ECHO OFFSETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSIONPUSHD %~dp0FOR %%A IN (*-KB*.MSU) DO (<SNIP />So this is the script I should use? What about the exe files?If you'd looked a little harder you'd have also noticed an example script for .EXE files too!All that was needed was to join them into one, perhaps something like this UnTested:Example for recursion:@ECHO OFFSETLOCAL ENABLEEXTENSIONS DISABLEDELAYEDEXPANSIONFOR /R "%~dp0" %%A IN (*-KB*.*) DO ( IF /I %%~xA==.MSU (SET _=WUSA) ELSE ( IF /I NOT %%~xA==.EXE GOTO :EOF SET "_=") CALL :SUB "%%~nA" >NUL TIMEOUT /t 3 %_% "%%A" /quiet /norestart)ECHO= == Press any key to restart ==>NUL PAUSESHUTDOWN /rGOTO :EOF:SUB SET "KB_NUM=%*" FOR /F "DELIMS=-" %%B IN ("%KB_NUM:*-KB=%") DO ( ECHO= Installing KB%%B)Example for all in same directory:@ECHO OFFSETLOCAL ENABLEEXTENSIONS DISABLEDELAYEDEXPANSIONPUSHD %~dp0FOR %%A IN (*-KB*.*) DO ( IF /I %%~xA==.MSU (SET _=WUSA) ELSE ( IF /I NOT %%~xA==.EXE GOTO :EOF SET "_=") CALL :SUB %%~nA >NUL TIMEOUT /t 3 %_% "%%~fA" /quiet /norestart)ECHO= == Press any key to restart ==>NUL PAUSESHUTDOWN /rGOTO :EOF:SUB SET "KB_NUM=%*" FOR /F "DELIMS=-" %%B IN ("%KB_NUM:*-KB=%") DO ( ECHO= Installing KB%%B)
DosProbie Posted December 25, 2013 Posted December 25, 2013 (edited) I use this in my 8.1 ua install (batch script is run outside of the Updates\msu directory and should wk with 7 as well), does a update count then log file when done..Happy HolidaysDP @echo off&setlocal ENABLEDELAYEDEXPANSION&color 1f&&title, [ WUSA - 8.1 UPDATE INSTALLER ]pushD "%~dp0" & cd /d "%~dp0":: ### SCAN FOR UPDATES ----------------------------------------------------------for /F %%a in ('dir Updates\msu\*.msu ^|findstr /i "file(s)"') do set z=%%a echo Number Of Updates Found: %z%echo:&echo::: ### INSTALLING UPDATES (reads updates in numerical order)--------------------- echo == Installing %z% Windows Updates..(This may take a while, Please Wait)echo:for /R "%~dp0" %%A IN (*.MSU) DO ( SET /A COUNT+=1 ECHO= Installing !COUNT! of %z% = %%~nA >NUL TIMEOUT /t 3 start /wait WUSA "%%A" /quiet /norestart)popDendlocalgoto :wpi:wpi:: ### DATED UPDATE LOG FILE WHEN DONE-------------------------------------------set wusa=%systemdrive%\HotFixes-%date:~10,4%-%date:~4,2%-%date:~7,2%-%date:~0,3%.htmwmic qfe list full /format:htable>%wusa% Edited December 25, 2013 by DosProbie
magsoud Posted February 10, 2014 Posted February 10, 2014 (edited) How Show Progress Bar with Percent (0~100) for any msu file? Edited February 10, 2014 by magsood
yro Posted October 10, 2014 Posted October 10, 2014 Guys Im lost here. I need a script to install all msu files on a folder but I need this script to "ignore" an update if its already installed on the system. Is that the normal behavior of these scripts? If not, how can I make this script do the ignore installed thing? script in use is this: @echo offTITLE INSTALADOR DE ATUALIZACOES DO WINDOWSCLSsetlocal ENABLEDELAYEDEXPANSIONpushd "%~dp0"echo:echo PREPARANDO ATUALIZACOES..echo:for /F %%a in ('dir *.msu ^| find /i "file(s)"') do set z=%%aif "%z%"=="" goto :Failureecho Atualizacoes encontradas: %z%echo:echo Instalando atualizacoes... (Esta tarefa pode demorar)echo:FOR /R "%~dp0" %%A IN (*.MSU) DO ( SET /A COUNT+=1 ECHO= Instalando !COUNT! de %z% = %%~nA >NUL TIMEOUT /t 3 WUSA "%%A" /quiet /norestart)echo Instaladas %z% atualizacoes dia %date% as %time%.echo:echo Reinicie o seu computador!CHOICE /C YN /N /M "Reiniciar agora? [Y]es [N]o :"if %errorlevel%==1 goto :Rebootif %errorlevel%==2 goto :Exit:FailureCLSecho ==========================================================echo:echo NENHUMA ATUALIZACAO ENCONTRADAecho:echo ATENCAO: As atualizacoes precisam estar na mesma pasta onde este script se encontra.echo:echo ==========================================================echo:pausegoto :Exit:RebootENDLOCALstart shutdown.exe /r /t 0 :ExitENDLOCALexit
jaclaz Posted October 12, 2014 Posted October 12, 2014 I don' tget it.Where does that script come from?Have you written it?What does it does? (I mean does it actually, even minimally, work?) If you set a variable inside a FOR loop, it's "%" value won't be altered, you need to use the expanded "!" value. Example:@ECHO OFFSETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSIONSET Variable=A suffusion of yellowFOR /L %%A IN (1,1,10) DO (SET Variable=%%AECHO %Variable%ECHO !Variable!)jaclaz
yro Posted October 14, 2014 Posted October 14, 2014 sorry jaclass. that was just a concept that I found (i guess in this forum). I have a fully functional script here but unfortunately its not worth. The script takes too long to install all the msus i have. Now im trying to figureout how to make ntlites nuyhi tool to work with the updates and some removals thanks anyway... sorry about my bad english..
MHz Posted October 15, 2014 Posted October 15, 2014 (edited) yro, The update files have a KB number in the filenames and systeminfo gives KB numbers installed so I looked at how the data could be used to set which filename to allow to be installed. This is a test script I came up with.@echo offsetlocal enabledelayedexpansion:: Set a counter for the KB[i] series of variablesset i=0:: Find installed KB numbers from systeminfo and add to KB[i] variablesfor /f "tokens=2" %%A in ('systeminfo^|findstr /i "\<KB[0-9][0-9]*$"') do ( set /a i += 1 set KB[!i!]=%%A):: Set ubound to 1st KB variableset KB[0]=%i%:: Loop through recursive search for msu files:: In each filename, find KB number, if not found then install filename:: Remove the echo in front of wusa used in testing to execute the wusa:: command and remove the pause linefor /R "%~dp0" %%U in (*.msu) do ( set /a count += 1 set installed=0 echo Instalando !count! de %z% = %%~nU timeout /t 3 > nul for /l %%I in (1, 1, %KB[0]%) do ( echo %%~nU| find /i "!KB[%%I]!"> nul @if not errorlevel 1 set installed=1 ) @if !installed! equ 0 echo wusa "%%U" /quiet /norestart)endlocalpausegoto :eofIt puts each KB string into a variable KB where i is a numbered index (like how an array on access works). That makes the data easier to loop through many times over. If the KB string is found in the filename, then installed is set to 1 so installation will not happen. Edit: Added /i to find and findstr so case sensitivity would not be an issue. Edited October 15, 2014 by MHz
crobertson Posted February 18, 2015 Posted February 18, 2015 I changed the code to echo/push the update name into a text file. I really don't need/want to attempt all updates at one time. It needs to install in 2-3 updates.Can we use this text files at check if the update has already been installed?Currently I stop about 40-50% complete and reboot then start again, but it attempts to install from the very beginning. I tried to edit these scripts, but I'm not able to.any thoughts?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now