Help - Search - Members - Calendar
Full Version: [Help] go through each directory and replace all relevant files with n
MSFN Forums > Coding, Scripting and Servers > Programming (C++, Delphi, VB, etc.)

   


Google Internet Forums Unattended CD/DVD Guide
Bilou_Gateux
I have a directory tree and i would like to replace each file in this tree with the updated file from new service pack (if found).

The idea is to replace binaries from SP2 with the same from SP3 but don't touch registry hives.

NOTE:
I can't use the regular SP3_extracted\i386\update\update.exe from Service Pack to update OS because the target to update is before FBA Windows XP Embedded w/ SP2 run-time image. FBA (First Boot Agent) completes the run-time image build process = setup in a regular Windows XP Professional install (GUI part of install after textmode copy step)

i use this script to get a list of all files to replace.
CODE
SET TARGETROOT=%1
FOR /F "USEBACKQ DELIMS==" %%h IN (`DIR /B /AD /S %TARGETROOT%`) DO (
       SET SRCPATH=%%h
      call :loop
       SET SRCPATH=
)
goto :eof
:loop
echo/[%SRCPATH%]>>%temp%\filelist.txt
      
FOR /F "USEBACKQ DELIMS==" %%I IN (`DIR /B /A-D /OGN %SRCPATH%\*`) DO (
  echo/%%~nxI>> %temp%\filelist.txt
)
goto :eof


for each file in the list, i have to check if updated binary exists in SP3_extracted\i386 folder and copy SP3_extracted\i386\%%~nxI to %SRCPATH%

filelist.txt
CODE
[D:\Windows]
explorer.exe
explorer.scf
hh.exe
msdfmap.ini
NOTEPAD.EXE
regedit.exe
twain.dll
twain_32.dll
twunk_16.exe
twunk_32.exe
WinSetup.log
[D:\Windows\AppPatch]
AcGenral.dll
AcLayers.dll
AcLua.dll
AcSpecfc.dll
AcVerfyr.dll
AcXtrnal.dll
apphelp.sdb
drvmain.sdb
msimain.sdb
sysmain.sdb
[D:\Windows\Cursors]
...


i have a few files exceptions i have to take care before replacing them:
if ACPIAPIC_UP ntoskrnl.exe=ntoskrnl.exe
if ACPIAPIC_UP hal.exe=halaacpi.dll
and a dir exception
skip D:\Windows\system32\config
Yzöwl
Ignoring the 'if ACPIAPIC_UP' lines, because I have no idea what you mean, here's a basic copy .cmd file which may help:
CODE
@Echo off&Setlocal
If Exist %1 (Pushd %1) Else Goto :Eof
Set "X_=X:\Path To\SP3_extracted\i386"
For /f "tokens=*" %%# In (
  'Dir/b/s/ad^|Find /v /i "\Windows\System32\config"') Do Call :_T %%#
Goto :Eof
:_T
Pushd %*
For /f "tokens=*" %%# In ('Dir/b/a-d') Do If Exist "%X_%\%%#" Copy "%X_%\%%#"
Popd
You'll need to change 'line 3' to the correct full path!
Bilou_Gateux
QUOTE (Yzöwl @ Jun 30 2009, 09:03 PM) *
Ignoring the 'if ACPIAPIC_UP' lines, [i]because I have no idea what you mean[/i


It's just a reminder. According to hal.inf and CPU, source files are different:
QUOTE
ACPIAPIC_UP_HAL, ACPIAPIC_UP ; ACPI APIC-based PC (UP)
ACPIAPIC_MP_HAL, ACPIAPIC_MP, ACPIAPIC_UP ; ACPI APIC-based PC (MP)

;****************************************************
; Files common to all x86 MP platforms
[MP.CopyFiles]
ntoskrnl.exe, ntkrnlmp.exe,,0x3000
ntkrnlpa.exe, ntkrpamp.exe,,0x3000
[ACPIAPIC_UP_HAL.CopyFiles]
hal.dll, halaacpi.dll,,0x3000

;****************************************************
; Files common to all x86 UP platforms
[UP.CopyFiles]
ntoskrnl.exe,,,0x3000
ntkrnlpa.exe,,,0x3000
[ACPIAPIC_MP_HAL.CopyFiles]
hal.dll, halmacpi.dll,,0x3000


i will probably update both files outside the script.

Just noticed files in X:\Path To\SP3_extracted\i386 are compressed, so i have to use an expand -r command instead of copy command. blushing.gif

how to change this command:
CODE
If Exist "%X_%\%%#" Copy "%X_%\%%#"


with expand command the source file has the last char of the extension replaced by a "low line" _ char.
ie with my previous list
CODE
if Exist "X:\Path To\SP3_extracted\i386\explorer.exe" expand -r "X:\Path To\SP3_extracted\i386\explorer.ex_" .


ie explorer.exe %~nx0
return
explorer.ex_ %~n0 + 2 characters of extension %~x0 + _




Google Internet Forums Unattended CD/DVD Guide

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.