MSFN Forum: [Help] go through each directory and replace all relevant files with n - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[Help] go through each directory and replace all relevant files with n batch script Rate Topic: -----

#1 User is offline   Bilou_Gateux 

  • Powered by Windows Embedded
  • PipPipPipPipPip
  • Group: Members
  • Posts: 766
  • Joined: 03-January 04

Posted 30 June 2009 - 09:13 AM

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

This post has been edited by Bilou_Gateux: 30 June 2009 - 09:39 AM



#2 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,116
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 30 June 2009 - 01:03 PM

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!

#3 User is offline   Bilou_Gateux 

  • Powered by Windows Embedded
  • PipPipPipPipPip
  • Group: Members
  • Posts: 766
  • Joined: 03-January 04

Posted 01 July 2009 - 08:08 AM

View PostYzöwl, on Jun 30 2009, 09:03 PM, said:

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:

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

This post has been edited by Bilou_Gateux: 01 July 2009 - 09:25 AM


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy