Jump to content

[Help] go through each directory and replace all relevant files with n


Recommended Posts

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.

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

[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

Edited by Bilou_Gateux
Link to comment
Share on other sites


Ignoring the 'if ACPIAPIC_UP' lines, because I have no idea what you mean, here's a basic copy .cmd file which may help:

@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!

Link to comment
Share on other sites

Ignoring the 'if ACPIAPIC_UP' lines, because I have no idea what you mean[/i

It's just a reminder. According to hal.inf and CPU, source files are different:

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:

how to change this command:

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

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 + _

Edited by Bilou_Gateux
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.


×
×
  • Create New...