Jump to content

Rearranged Offline Update


Recommended Posts

I didn't understand how I will do

my os turkish

@Echo off
TITLE Vista Update Integration (offline)

::-------------------------------------------------------------------
::Purpose: Batch integrates msu update files into install.wim offline
::
::CALL: Called by user
::
::Requirements: install.wim has to be mounted to %VMount% already!!!
::
::Version: 1.0.1
::
::History:
::
::Changes by 1.0.1:
:: 1. Added further Explanations for pkgmgr.exe call
:: 2. Added further Explanations for "DIR /OD >sort.txt" line
:: 3. Changed the value in the following line, which was
:: For /F "Tokens=4" %%i IN ('FINDSTR ".cab" Sort.txt') DO Call :WriteXML %%i
:: and is now
:: For /F "Tokens=5" %%i IN ('FINDSTR ".cab" Sort.txt') DO Call :WriteXML %%i
:: Change was necessary to get it worked with English OS
::-------------------------------------------------------------------



::Check environment
::Fist of all is checked, if all used environment variables are declared and valid and if
::all used directories do exist. This done by check_umgebung.cmd.
::
::check_umgebung.cmd will assign a value "true" to EnvErr variable, if there is an error in
::working environment and it will assign "false" to EnvErr variable, if everything is alright
::in working evrionment.
::
::If there is an error in working environment (EnvErr=true) au_fehler.cmd is called.
::au_fehler.cmd will display an error message and quit the batch.

CALL check_umgebung.cmd
IF %EnvErr%==true CALL au_fehler.cmd


::You need to adpat the following SET lines, if your system was not prepared or not prepared
::correctly using preplab.cmd. Remove everything in front of SET and adjust the path behind
::"=". Expect PMgrDir - this is path where pkgmgr.exe is located - all pahtes are arbitrary.
::---- Start Adjustment ------------------------------------------------------------------------
::SET PMgrDir=%Programfiles%\Windows AIK\Tools\Servicing
::SET VMount=C:\WinPERE\Mount
::SET VUpdates=J:\Vista\Updates
::SET VSand=C:\WinPERE\Sandbox
::SET VLog=C:\WinPERE
::---- End Adjustment -------------------------------------------------------------------------

::The nex step is necessarry, cause Expand.exe is inside different folders depending on OS.
::In Vista Expand.exe is located in %Windir%\System32 in XP it's located inside same
::folder like package manager (%PMgrDir%).

SET Extract=%PMgrDir%
IF NOT EXIST "%PMgrDir%"\Expand.exe SET Extract=%Windir%\System32



::____________________________________________________________________________________
:: MAIN PROCEDURE
::____________________________________________________________________________________


::Creating an temporary directory inside Updates folder. The msu files will be extracted
::to that new temporary folder.

IF NOT EXIST %VUpdates%\Temp (MKDIR %VUpdates%\Temp)
DEL %VUpdates%\Temp\*.* /q


::PUSHD will jump to %VUpdates% folder. Than all present files inside Updates folder are
::assigned to :Extract subroutine.

PUSHD %VUpdates%
FOR %%i IN (*) DO (Call :Extract %%i)


::Checking for older file version created by this batch before may be and deleting them
::if necessary to avoid any conflicts.

IF EXIST %VUpdates%\Temp\integrate.xml DEL /Q %VUpdates%\Temp\integrate.xml
IF EXIST %VUpdates%\Temp\Sort.txt DEL /Q %VUpdates%\Temp\Sort.txt


::The following three ECHO lines are redirected into integrate.xml file.
::So they are building the first lines of integrate.xml.

ECHO ^<^?xml version="1.0" encoding="utf-8"?^>^ >>%VUpdates%\Temp\integrate.xml
ECHO ^<^unattend xmlns="urn:schemas-microsoft-com:unattend"^>^ >>%VUpdates%\Temp\integrate.xml
ECHO ^<^servicing^>^ >>%VUpdates%\Temp\integrate.xml


::PUSHD jumps into %VUpdates%\Temp folder.
::Dir /OD lists all the files inside Temp folder by date. The output is redirected to Sort.txt.
::
::NOTE:
::Dir /OD output can be different depending on OS language you're using, so you may need to adjust
::the Tokens value in the following line!
::
::Example:
::Dir /OD output on German OS:
::
::12.02.2007 00:25 4.321.981 Windows6.0-KB929427-x86.msu
::12.02.2007 00:27 394.535 Windows6.0-KB925528-x86.msu
:: | | | |
:: Token 1 Token 2 Token 3 Token 4
::
::
::Dir /OD output on English OS:
::
:: Token 3
:: |
::12.02.2007 00:25 AM 4.321.981 Windows6.0-KB929427-x86.msu
::12.02.2007 00:27 AM 394.535 Windows6.0-KB925528-x86.msu
:: | | | |
:: Token 1 Token 2 Token 4 Token 5
::
::
::The following FOR loop is searching cab files inside the sort.txt list and forwards the
::file name of them (sorted out by Tokens value) - if found - to WriteXML subroutine.

PUSHD %VUpdates%\Temp
Dir /OD > Sort.txt
For /F "Tokens=5" %%i IN ('FINDSTR ".cab" Sort.txt') DO Call :WriteXML %%i


::Now the two finishing lines are added to integrate.xml. Again the ECHO commands are
::redirected to do so.

ECHO ^<^/servicing^>^ >>%VUpdates%\Temp\integrate.xml
ECHO ^<^/unattend^>^ >>%VUpdates%\Temp\integrate.xml


::At least package manager (pkgmgr.exe) is executed and installs the packages using following
::parameters:
::
::/o: points to the folder where image is mounted to and defines the windows folder inside
:: the mounted image.
::
::/n: assigns the answer file (xml file) containing the informations about the updates, which
:: supposed to be installed.
::
::/s: points to the sandbox folder (temporary folder) which will be used by package manager
:: to extract the cabs before integrating them.
::
::/l: points to the location of the log file and defines the name of the log.
::
::IMPORTANT:
::START command does interpret the first Expression inside qutes as Window Title. This is
::the reason, why you need "PMgr". You can rename but not remove it. Otherwise the whole
::command will fail!!!

START "PMgr" /WAIT "%PMgrDir%\pkgmgr.exe" /o:%VMount%;%VMount%\Windows /n:%VUpdates%\Temp\integrate.xml /s:%VSandb% /l:%VLog%\pkglog.txt
ECHO The process of integration was finished with error level %ERRORLEVEL%.
RD %VSandb% /q /s
DEL %VUpdates%\Temp\*.* /q
MKDIR %VWork%\Sandbox
Pause
EXIT



::____________________________________________________________________________
:: SUB PROCEDURES & PARTS EXECUTED OPTIONAL
::____________________________________________________________________________


::Extract subroutine extracts the msu files die MSU-Dateien from %VUpdates% directory
::to %VUpdates%\Temp. There they will be present with same names but cab format.

:Extract
START "Expand" /WAIT "%Extract%"\Expand.exe %1 -f:* %VUpdates%\Temp
GOTO :EOF


::WriteXML subroutine writes entries into integrate.xml, which are specified by the name of
::coresponding cab file. This is the command line, which will call the installation of the
::cab during pkgmgr procedure later.

:WriteXML
IF "%1"=="WSUSSCAN.cab" Goto :EOF
SET Name=%1
IF ".%Name%"=="." GOTO :EOF
SET XML=%Name:~0,-4%.xml
SET Cab=%Name:~0,-4%.cab
ECHO ^<^package action="install"^>^ >>%VUpdates%\Temp\integrate.xml
FOR /F "Tokens=*" %%i IN ('FINDSTR "assemblyIdentity" %XML%') DO (Echo %%i >>%VUpdates%\Temp\integrate.xml)
ECHO ^<^source location="%VUpdates%\Temp\%Cab%" /^>^ >>%VUpdates%\Temp\integrate.xml
ECHO ^<^/package^>^ >>%VUpdates%\Temp\integrate.xml
:EOF

I solved the problem

Edited by tozo
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...