Or see if redirection BEFORE line works
The full script itself got pretty long but here are main parts of it:1. Unpacking files to HFMER folder.
IF EXIST HF\*.EXE (
IF EXIST HFMER RD/Q/S HFMER
IF EXIST TEMP RD/Q/S TEMP
MD HFMER TEMP
FOR /F %%I IN ('DIR/A-D/B HF') DO (
ECHO.&ECHO Unpacking %%I
MD TEMP\HFMER&START/WAIT HF\%%I /Q /X:TEMP\HFMER
XCOPY/DEHRY TEMP\HFMER HFMER
IF EXIST TEMP\HFMER\UPDATE\update.inf COPY/B TEMP\HFMER\UPDATE\update.inf TEMP\%%I.inf >NUL
IF EXIST TEMP\HFMER\UPDATE\update_w2k.inf COPY/B TEMP\HFMER\UPDATE\update_w2k.inf TEMP\%%I.inf >NUL
IF EXIST TEMP\HFMER\UPDATE\update_win2k.inf COPY/B TEMP\HFMER\UPDATE\update_win2k.inf TEMP\%%I.inf >NUL
IF EXIST TEMP\HFMER\UPDATE\update.ver COPY/B TEMP\HFMER\UPDATE\update.ver TEMP\%%I.ver >NUL
RD/Q/S TEMP\HFMER >NUL
2. Merging update.ver
:: merging update.ver
ECHO.&ECHO Merging update.ver...&ECHO.
FOR /F %%A IN ('DIR/B TEMP\*.ver') DO (
FOR /F "skip=1 tokens=*" %%B IN (TEMP\%%A) DO (
ECHO TEMP\%%A -- %%B
ECHO %%B >>TEMP\update.txt
ECHO [SourceFileInfo] >TEMP\update.ver
SORT TEMP\update.txt >>TEMP\update.ver
:: removing duplicates in update.ver
TOOLS\yanklines.vbs TEMP\update.ver HFMER\UPDATE\update.ver >NUL
I had to modify yanklines in order to prevent new cmd.exe windows from popping up. I modified this line
scriptCommand = "cmd.exe /k "
scriptCommand = "cmd.exe /c "
The window still pops up but gets closed instantly.3. Merging update.inf by jaclaz's script & yanklines
ECHO.&ECHO Merging update.inf...&ECHO.
COPY/B TOOLS\jaclaz\*.* >NUL
COPY/B HFMER\update\update.inf update.inf >NUL
splitinf.cmd update.inf >NUL
:: yanklines SPLIT_update\*.inf
XCOPY/EI SPLIT_update TEMP\SPLIT_update >NUL
IF EXIST TEMP\SPLIT_update\[1ndex]update.inf DEL/Q TEMP\SPLIT_update\[1ndex]update.inf >NUL
IF EXIST TEMP\SPLIT_update\*Add.Reg*]update.inf DEL/Q TEMP\SPLIT_update\*Add.Reg*]update.inf >NUL
IF EXIST TEMP\SPLIT_update\*AddReg*]update.inf DEL/Q TEMP\SPLIT_update\*AddReg*]update.inf >NUL
IF EXIST TEMP\SPLIT_update\[Strings]update.inf DEL/Q TEMP\SPLIT_update\[Strings]update.inf >NUL
FOR /F %%I IN ('DIR/B TEMP\SPLIT_update') DO (
START/WAIT TOOLS\yanklines.vbs TEMP\SPLIT_update\%%I SPLIT_UPDATE\%%I >NUL
join_dedupe_inf.cmd SPLIT_update.inf >NUL
beautify.cmd JOINED_update.inf >NUL
MOVE/Y BEAUTY_JOINED_update.inf HFMER\update\update.inf >NUL
DEL/Q update.inf splitinf.cmd join_dedupe_inf.cmd beautify.cmd fedit.exe gsar.exe split_update.inf joined_update.inf >NUL
RD/Q/S SPLIT_update >NUL
RD/Q/S TEMP >NUL
I know it's not ideal and many bypasses are used to make it work... but it does the job. Actually I've just noticed that deleting the *.inf files (look above) is not necessary anymore. They are related to CMSORT which I replaced with yanklines which is better and simpler, and what's the most important - it doesn't sort which is crucial in case of *Add*Reg* sections.4. SP part
- it's not finished yet and pretty long
The main points are:
- To remove all duplicate files from the original SP. A lot of files from ia/id/is/ip folders overlap each other. The method I use to dedupe them is to make new folders (iads, iadw, etc.) and move shared files according to the edition of 2K they are related to. After that the update.inf has to be changed too (this part is not ready yet).
- Replace installer files with the ones from Gurgelmeyer's USP5 which ignore M$ digital signatures.
- Update SP files with new versions. This is the most problematic part. First of all, it's easy to update files that are already in SP4. They can just be directly replaced and no changed to the update.inf are needed. The problem is with those files that do not originally belong to SP4. In order to add them, the update.inf has to be edited and it is complicated as it can't be done by just merging the update.inf from HFMER\update with the one from SP4. There are additional sections which are related to the /integrate switch ([ServicePackFiles], etc.) and new files must be placed there in order to get integrated. These sections are empty in normal (non-SP) updates. The other issue is that SP4's update.inf is old and its structure is a little different than update.infs from newer updates. By processing them by jaclaz's script many unnecessary and overlapping lines get inserted. The way to fix it would be to 'update' the SP4's update.inf to make it more similar to the newer ones. Some of the older updates are also affected by this issue. The same 'updating' thing probably must be done to the update.inf merged by the script. I'll have to work on it separately.
- New files (not belonging to the original SP4) are placed in a new folder (i386\SP6) to have them separated from the rest. They are also checked against the original W2K CD i386 files to know which of them can be compressed (makecab) and which not. Files which are not present either in SP4 or the 2K CD get copied to i386\SP6\new.
That's all for now. There are still many things to do, especially related to the merged update.inf file. I'm open to any ideas about how to change and what to improve in the script.
Edited by tomasz86, 05 August 2011 - 11:53 AM.