tomasz86 Posted August 4, 2011 Author Share Posted August 4, 2011 (edited) I want to edit lines in the original update.inf from w2k sp4 (after processing it by jaclaz's script to remove unnecessary spaces). Is there any better (but still simple) way than this one?SETLOCAL ENABLEDELAYEDEXPANSION@ECHO OFF > update.txtFOR /F "tokens=* delims= " %%I IN (update.inf) DO ( IF "%%I"=="CatalogFile = sp4.cat" ( ECHO ThisServicePackBuild = 1 >> update.txt ) ELSE ( ECHO %%I >> update.txt ))@ECHO OFF > update2.txtFOR /F "tokens=* delims= " %%I IN (update.txt) DO ( IF "%%I"=="MaxNtServicePackVersion = 1024 " ( ECHO MaxNtServicePackVersion = 1536 >> update2.txt ) ELSE ( ECHO %%I >> update2.txt ))@ECHO OFF > update3.txtFOR /F "tokens=* delims= " %%I in (update2.txt) do ( IF "%%I"=="ThisServicePackVersion = 1024 " ( ECHO ThisServicePackVersion = 1536 >> update3.txt ) ELSE ( ECHO %%I >> update3.txt ))The problem is that one space at the end of each line is added in each newer file so it goes like this:IF "%%I"=="CatalogFile = sp4.cat" <- no spaceIF "%%I"=="MaxNtServicePackVersion = 1024 "<- 1 spaceIF "%%I"=="ThisServicePackVersion = 1024 " <- 2 spaces...The other issue is that the script doesn't work if the output files are '.inf' files instead of '.txt' files. Why is this so? Edited August 4, 2011 by tomasz86 Link to comment Share on other sites More sharing options...
bphlpt Posted August 4, 2011 Share Posted August 4, 2011 The space problem is being caused because you're making things too "neat" and "human readable". You have a space before ">> update.txt", so it adds a space. Batch is usually very literal when it comes to using redirection and comparison testing. You don't need any spaces before or after the ">>" or ">", unless you are trying to add them on purpose. In your case, I think if you change your code to:SETLOCAL ENABLEDELAYEDEXPANSION@ECHO OFF>update.txtFOR /F "tokens=* delims= " %%I IN (update.inf) DO ( IF "%%I"=="CatalogFile = sp4.cat" ( ECHO ThisServicePackBuild = 1>>update.txt ) ELSE ( ECHO %%I>>update.txt ))@ECHO OFF>update2.txtFOR /F "tokens=* delims= " %%I IN (update.txt) DO ( IF "%%I"=="MaxNtServicePackVersion = 1024" ( ECHO MaxNtServicePackVersion = 1536>>update2.txt ) ELSE ( ECHO %%I>>update2.txt ))@ECHO OFF>update3.txtFOR /F "tokens=* delims= " %%I in (update2.txt) do ( IF "%%I"=="ThisServicePackVersion = 1024" ( ECHO ThisServicePackVersion = 1536>>update3.txt ) ELSE ( ECHO %%I>>update3.txt ))that should take care of your spacing problem.Cheers and Regards Link to comment Share on other sites More sharing options...
Yzöwl Posted August 4, 2011 Share Posted August 4, 2011 I see a potential problem with the example supplied by bphlpt above: ECHO ThisServicePackBuild = 1>> update.txtThe problem is that we generally use lazy redirection, when we write to stdout. ( >output.ext should be written as 1>output.ext )This means that I'd expect stdout to not receive the value of ThisServicePackBuild. Link to comment Share on other sites More sharing options...
jaclaz Posted August 4, 2011 Share Posted August 4, 2011 As always Yzöwl is right, if you have no space between the 1 and the > you will redirect standard output to file.You can always leave the spaces and post-process with gsar changing [sPACE][CR][LF] to [CR][LF] .... Or see if redirection BEFORE line works, see point #(3) here:http://www.robvanderwoude.com/redirection.phpjaclaz Link to comment Share on other sites More sharing options...
allen2 Posted August 4, 2011 Share Posted August 4, 2011 (ECHO ThisServicePackBuild = 1)>> update.txtor(ECHO ThisServicePackBuild = 1)1>> update.txtwill work. Link to comment Share on other sites More sharing options...
tomasz86 Posted August 5, 2011 Author Share Posted August 5, 2011 (edited) Or see if redirection BEFORE line worksIt works Thank you.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 ECHO. XCOPY/DEHRY TEMP\HFMER HFMER ECHO. 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 CLS 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 >NULI had to modify yanklines in order to prevent new cmd.exe windows from popping up. I modified this linescriptCommand = "cmd.exe /k "toscriptCommand = "cmd.exe /c "The window still pops up but gets closed instantly.3. Merging update.inf by jaclaz's script & yanklines CLS 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 >NULI 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:SP IF EXIST HFMER\i386 RD/Q/S HFMER\i386 >NUL IF EXIST TEMP RD/Q/S TEMP >NUL MD TEMP :: preparing HFMER DEL/Q HFMER\empty.cat HFMER\iecustom.dll HFMER\spmsg.dll HFMER\spuninst.exe HFMER\updcustom.dll >NUL IF EXIST HFMER\XPSP2_BINARYDROP ( COPY/B/Y HFMER\XPSP2_BINARYDROP\*.* HFMER\ >NUL RD/Q/S HFMER\XPSP2_BINARYDROP >NUL ) :: unpacking SP archive CLS ECHO.&ECHO Unpacking Service Pack files...&ECHO. FOR /F %%I IN ('DIR/A-D/B SP') DO ( START/WAIT SP\%%I /Q /X:HFMER\ ) :: preparing SP files and removing duplicates :: moving files from i386\i* to i386 MD HFMER\i386\iads HFMER\i386\iadsw HFMER\i386\iadw HFMER\i386\iapsw HFMER\i386\iasw HFMER\i386\iaw HFMER\i386\ips MOVE HFMER\i386\ia\basicwk.in_ HFMER\i386\&DEL/Q HFMER\i386\id\basicwk.in_ HFMER\i386\ip\basicwk.in_ HFMER\i386\is\basicwk.in_ HFMER\i386\iw\basicwk.in_ MOVE HFMER\i386\ia\dcup5.in_ HFMER\i386\&DEL/Q HFMER\i386\id\dcup5.in_ HFMER\i386\ip\dcup5.in_ HFMER\i386\is\dcup5.in_ HFMER\i386\iw\dcup5.in_ MOVE HFMER\i386\ia\defltdc.in_ HFMER\i386\&DEL/Q HFMER\i386\id\defltdc.in_ HFMER\i386\ip\defltdc.in_ HFMER\i386\is\defltdc.in_ HFMER\i386\iw\defltdc.in_ MOVE HFMER\i386\ia\defltwk.in_ HFMER\i386\&DEL/Q HFMER\i386\id\defltwk.in_ HFMER\i386\ip\defltwk.in_ HFMER\i386\is\defltwk.in_ HFMER\i386\iw\defltwk.in_ MOVE HFMER\i386\ia\dmreg.inf HFMER\i386\&DEL/Q HFMER\i386\id\dmreg.inf HFMER\i386\ip\dmreg.inf HFMER\i386\is\dmreg.inf HFMER\i386\iw\dmreg.inf MOVE HFMER\i386\ia\dwup.in_ HFMER\i386\&DEL/Q HFMER\i386\id\dwup.in_ HFMER\i386\ip\dwup.in_ HFMER\i386\is\dwup.in_ HFMER\i386\iw\dwup.in_ MOVE HFMER\i386\ia\fp40ext.in_ HFMER\i386\&DEL/Q HFMER\i386\id\fp40ext.in_ HFMER\i386\ip\fp40ext.in_ HFMER\i386\is\fp40ext.in_ HFMER\i386\iw\fp40ext.in_ MOVE HFMER\i386\ia\hivecls.inf HFMER\i386\&DEL/Q HFMER\i386\id\hivecls.inf HFMER\i386\ip\hivecls.inf HFMER\i386\is\hivecls.inf HFMER\i386\iw\hivecls.inf MOVE HFMER\i386\ia\mchgr.in_ HFMER\i386\&DEL/Q HFMER\i386\id\mchgr.in_ HFMER\i386\ip\mchgr.in_ HFMER\i386\is\mchgr.in_ HFMER\i386\iw\mchgr.in_ MOVE HFMER\i386\ia\sceregvl.in_ HFMER\i386\&DEL/Q HFMER\i386\id\sceregvl.in_ HFMER\i386\ip\sceregvl.in_ HFMER\i386\is\sceregvl.in_ HFMER\i386\iw\sceregvl.in_ MOVE HFMER\i386\ia\tape.in_ HFMER\i386\&DEL/Q HFMER\i386\id\tape.in_ HFMER\i386\ip\tape.in_ HFMER\i386\is\tape.in_ HFMER\i386\iw\tape.in_ MOVE HFMER\i386\ia\usb.in_ HFMER\i386\&DEL/Q HFMER\i386\id\usb.in_ HFMER\i386\ip\usb.in_ HFMER\i386\is\usb.in_ HFMER\i386\iw\usb.in_ :: iads MOVE HFMER\i386\ia\apcompat.in_ HFMER\i386\iads\&DEL/Q HFMER\i386\id\apcompat.in_ HFMER\i386\is\apcompat.in_ :: iadsw MOVE HFMER\i386\ia\comntsrv.in_ HFMER\i386\iadsw\&DEL/Q HFMER\i386\id\comntsrv.in_ HFMER\i386\is\comntsrv.in_ HFMER\i386\iw\comntsrv.in_ MOVE HFMER\i386\ia\hiveusd.inf HFMER\i386\iadsw\&DEL/Q HFMER\i386\id\hiveusd.inf HFMER\i386\is\hiveusd.inf HFMER\i386\iw\hiveusd.inf MOVE HFMER\i386\ia\iisdbg.in_ HFMER\i386\iadsw\&DEL/Q HFMER\i386\id\iisdbg.in_ HFMER\i386\is\iisdbg.in_ HFMER\i386\iw\iisdbg.in_ MOVE HFMER\i386\ia\machine.in_ HFMER\i386\iadsw\&DEL/Q HFMER\i386\id\machine.in_ HFMER\i386\is\machine.in_ HFMER\i386\iw\machine.in_ MOVE HFMER\i386\ia\netnwcli.in_ HFMER\i386\iadsw\&DEL/Q HFMER\i386\id\netnwcli.in_ HFMER\i386\is\netnwcli.in_ HFMER\i386\iw\netnwcli.in_ MOVE HFMER\i386\ia\netoc.in_ HFMER\i386\iadsw\&DEL/Q HFMER\i386\id\netoc.in_ HFMER\i386\is\netoc.in_ HFMER\i386\iw\netoc.in_ MOVE HFMER\i386\ia\netrass.in_ HFMER\i386\iadsw\&DEL/Q HFMER\i386\id\netrass.in_ HFMER\i386\is\netrass.in_ HFMER\i386\iw\netrass.in_ MOVE HFMER\i386\ia\netsnmp.in_ HFMER\i386\iadsw\&DEL/Q HFMER\i386\id\netsnmp.in_ HFMER\i386\is\netsnmp.in_ HFMER\i386\iw\netsnmp.in_ MOVE HFMER\i386\ia\netwlbsm.in_ HFMER\i386\iadsw\&DEL/Q HFMER\i386\id\netwlbsm.in_ HFMER\i386\is\netwlbsm.in_ HFMER\i386\iw\netwlbsm.in_ MOVE HFMER\i386\ia\ntfrsres.dl_ HFMER\i386\iadsw\&DEL/Q HFMER\i386\id\ntfrsres.dl_ HFMER\i386\is\ntfrsres.dl_ HFMER\i386\iw\ntfrsres.dl_ MOVE HFMER\i386\ia\setpwd.ex_ HFMER\i386\iadsw\&DEL/Q HFMER\i386\id\setpwd.ex_ HFMER\i386\is\setpwd.ex_ HFMER\i386\iw\setpwd.ex_ MOVE HFMER\i386\ia\wlbs.ch_ HFMER\i386\iadsw\&DEL/Q HFMER\i386\id\wlbs.ch_ HFMER\i386\is\wlbs.ch_ HFMER\i386\iw\wlbs.ch_ MOVE HFMER\i386\ia\wlbs.ex_ HFMER\i386\iadsw\&DEL/Q HFMER\i386\id\wlbs.ex_ HFMER\i386\is\wlbs.ex_ HFMER\i386\iw\wlbs.ex_ MOVE HFMER\i386\ia\wlbs.hl_ HFMER\i386\iadsw\&DEL/Q HFMER\i386\id\wlbs.hl_ HFMER\i386\is\wlbs.hl_ HFMER\i386\iw\wlbs.hl_ MOVE HFMER\i386\ia\wlbs.sy_ HFMER\i386\iadsw\&DEL/Q HFMER\i386\id\wlbs.sy_ HFMER\i386\is\wlbs.sy_ HFMER\i386\iw\wlbs.sy_ MOVE HFMER\i386\ia\wlbsctrl.dl_ HFMER\i386\iadsw\&DEL/Q HFMER\i386\id\wlbsctrl.dl_ HFMER\i386\is\wlbsctrl.dl_ HFMER\i386\iw\wlbsctrl.dl_ MOVE HFMER\i386\ia\wlbsprov.dl_ HFMER\i386\iadsw\&DEL/Q HFMER\i386\id\wlbsprov.dl_ HFMER\i386\is\wlbsprov.dl_ HFMER\i386\iw\wlbsprov.dl_ MOVE HFMER\i386\ia\wlbsprov.mf_ HFMER\i386\iadsw\&DEL/Q HFMER\i386\id\wlbsprov.mf_ HFMER\i386\is\wlbsprov.mf_ HFMER\i386\iw\wlbsprov.mf_ MOVE HFMER\i386\ia\wlbsprov.mo_ HFMER\i386\iadsw\&DEL/Q HFMER\i386\id\wlbsprov.mo_ HFMER\i386\is\wlbsprov.mo_ HFMER\i386\iw\wlbsprov.mo_ :: iadw MOVE HFMER\i386\ia\basicsv.in_ HFMER\i386\iadw\&DEL/Q HFMER\i386\id\basicsv.in_ HFMER\i386\iw\basicsv.in_ MOVE HFMER\i386\ia\defltsv.in_ HFMER\i386\iadw\&DEL/Q HFMER\i386\id\defltsv.in_ HFMER\i386\iw\defltsv.in_ MOVE HFMER\i386\ia\dsup.in_ HFMER\i386\iadw\&DEL/Q HFMER\i386\id\dsup.in_ HFMER\i386\iw\dsup.in_ :: iapsw MOVE HFMER\i386\drvindex.inf HFMER\i386\iapsw\&DEL/Q HFMER\i386\ia\drvindex.inf HFMER\i386\ip\drvindex.inf HFMER\i386\is\drvindex.inf HFMER\i386\iw\drvindex.inf MOVE HFMER\i386\ia\e100bnt5.sy_ HFMER\i386\iapsw\&DEL/Q HFMER\i386\ip\e100bnt5.sy_ HFMER\i386\is\e100bnt5.sy_ HFMER\i386\iw\e100bnt5.sy_ MOVE HFMER\i386\ia\hptxnt5.sy_ HFMER\i386\iapsw\&DEL/Q HFMER\i386\ip\hptxnt5.sy_ HFMER\i386\is\hptxnt5.sy_ HFMER\i386\iw\hptxnt5.sy_ MOVE HFMER\i386\ia\ibmfent5.sy_ HFMER\i386\iapsw\&DEL/Q HFMER\i386\ip\ibmfent5.sy_ HFMER\i386\is\ibmfent5.sy_ HFMER\i386\iw\ibmfent5.sy_ MOVE HFMER\i386\ia\netcpqg.in_ HFMER\i386\iapsw\&DEL/Q HFMER\i386\ip\netcpqg.in_ HFMER\i386\is\netcpqg.in_ HFMER\i386\iw\netcpqg.in_ MOVE HFMER\i386\ia\netcpqi.in_ HFMER\i386\iapsw\&DEL/Q HFMER\i386\ip\netcpqi.in_ HFMER\i386\is\netcpqi.in_ HFMER\i386\iw\netcpqi.in_ MOVE HFMER\i386\ia\netel90x.in_ HFMER\i386\iapsw\&DEL/Q HFMER\i386\ip\netel90x.in_ HFMER\i386\is\netel90x.in_ HFMER\i386\iw\netel90x.in_ MOVE HFMER\i386\ia\scsi.in_ HFMER\i386\iapsw\&DEL/Q HFMER\i386\ip\scsi.in_ HFMER\i386\is\scsi.in_ HFMER\i386\iw\scsi.in_ :: iasw MOVE HFMER\i386\ia\hivesft.inf HFMER\i386\iasw\&DEL/Q HFMER\i386\is\hivesft.inf HFMER\i386\iw\hivesft.inf MOVE HFMER\i386\ia\hivesys.inf HFMER\i386\iasw\&DEL/Q HFMER\i386\is\hivesys.inf HFMER\i386\iw\hivesys.inf :: iaw MOVE HFMER\i386\ia\dosnet.inf HFMER\i386\iaw\&DEL/Q HFMER\i386\iw\dosnet.inf MOVE HFMER\i386\ia\syssetup.in_ HFMER\i386\iaw\&DEL/Q HFMER\i386\iw\syssetup.in_ :: ips MOVE HFMER\i386\ip\basicsv.in_ HFMER\i386\ips\&DEL/Q HFMER\i386\is\basicsv.in_ MOVE HFMER\i386\ip\defltsv.in_ HFMER\i386\ips\&DEL/Q HFMER\i386\is\defltsv.in_ MOVE HFMER\i386\ip\dsup.in_ HFMER\i386\ips\&DEL/Q HFMER\i386\is\dsup.in_ MOVE HFMER\i386\ip\setupreg.hiv HFMER\i386\ips\&DEL/Q HFMER\i386\is\setupreg.hiv :: modyfing update.inf @ECHO OFF>update.txt FOR /F "tokens=* delims= " %%I IN (update.inf) DO ( IF "%%I"=="CatalogFile = sp4.cat" ( >>update.txt ECHO ThisServicePackBuild = 1 ) ELSE ( ECHO %%I>>update.txt ) ) @ECHO OFF>update2.txt FOR /F "tokens=* delims= " %%I IN (update.txt) DO ( IF "%%I"=="MaxNtServicePackVersion = 1024" ( >>update2.txt ECHO MaxNtServicePackVersion = 1536 ) ELSE ( ECHO %%I>>update2.txt ) ) @ECHO OFF>update3.txt FOR /F "tokens=* delims= " %%I in (update2.txt) do ( IF "%%I"=="ThisServicePackVersion = 1024" ( >>update3.txt ECHO ThisServicePackVersion = 1536 ) ELSE ( ECHO %%I>>update3.txt ) ) :: replacing original SP files with Gurgelmeyer XCOPY/SY TOOLS\SP51 HFMER\i386 >NUL :: updating sp4.cab ECHO.&ECHO Unpacking sp4.cab...&ECHO. MD TEMP\sp4cab&EXPAND -F:* HFMER\i386\new\sp4.cab TEMP\sp4cab >NUL FOR /F %%I IN ('DIR/B TEMP\sp4cab') DO ( IF EXIST HFMER\%%I ( ECHO Processing %%I XCOPY/DY HFMER\%%I TEMP\sp4cab\ >NUL ) ) ECHO.&ECHO Repacking sp4.cab... CABARC -m LZX:21 N HFMER\i386\new\sp4.cab TEMP\sp4cab\*.* >NUL RD/Q/S TEMP\sp4cab >NUL :: updating wms4.cab ECHO.&ECHO.&ECHO Unpacking wms4.cab&ECHO. MD TEMP\wms4cab&EXPAND -F:* HFMER\i386\wms4.cab TEMP\wms4cab >NUL IF EXIST HFMER\WMS ( FOR /F %%I IN ('DIR/B HFMER\WMS') DO ( IF EXIST HFMER\%%I ( XCOPY/DY HFMER\WMS\%%I HFMER\ >NUL DEL/Q HFMER\WMS\%%I ) ) ) FOR /F %%I IN ('DIR/B TEMP\wms4cab') DO ( IF EXIST HFMER\WMS\%%I ( ECHO Processing %%I XCOPY/DY HFMER\WMS\%%I TEMP\wms4cab\ >NUL ) IF EXIST HFMER\%%I ( ECHO Processing %%I XCOPY/DY HFMER\%%I TEMP\wms4cab\ >NUL ) ) ECHO.&ECHO Repacking wms4.cab... CABARC -m LZX:21 N HFMER\i386\wms4.cab TEMP\wms4cab\*.* >NUL RD/Q/S TEMP\wms4cab >NUL :: updating non-compressed SP files ECHO.&ECHO.&ECHO Verifying non-compressed Service Pack files...&ECHO. :: updating i386\system32 (ntdll.dll) FOR /F %%I IN ('DIR/B HFMER\i386\system32') DO ( IF EXIST HFMER\uniproc\%%I ( XCOPY/DY HFMER\uniproc\%%I HFMER\ >NUL ) IF EXIST HFMER\%%I ( ECHO Processing %%I XCOPY/DY HFMER\%%I HFMER\i386\system32\ >NUL ) ) :: updating i386\uniproc FOR /F %%I IN ('DIR/B HFMER\i386\uniproc') DO ( IF EXIST HFMER\uniproc\%%I ( ECHO Processing %%I XCOPY/DY HFMER\uniproc\%%I HFMER\i386\uniproc\ >NUL&DEL/Q HFMER\uniproc\%%I >NUL ) ) :: updating i386 FOR /F %%I IN ('DIR/A-D/B HFMER\i386') DO ( IF EXIST HFMER\%%I ( ECHO Processing %%I XCOPY/DY HFMER\%%I HFMER\i386\ >NUL&DEL/Q HFMER\%%I >NUL ) ) :: updating compressed SP files ECHO.&ECHO.&ECHO Verifying compressed Service Pack files...&ECHO. :: updating i386 FOR /F %%I IN ('DIR/A-D/B HFMER\i386\*.*_') DO ( EXPAND -R HFMER\i386\%%I TEMP\ >NUL FOR /F %%I IN ('DIR/A-D/B TEMP') DO ( IF EXIST HFMER\%%I ( ECHO Processing i386\%%I XCOPY/DY HFMER\%%I TEMP\ >NUL&DEL/Q HFMER\%%I >NUL MAKECAB /D CompressionMemory=21 /D CompressionType=LZX TEMP\%%I /L HFMER\i386 >NUL ) DEL/Q/S TEMP\%%I >NUL ) ) :: updating i386\lang\chs FOR /F %%I IN ('DIR/A-D/B HFMER\i386\lang\chs\*.*_') DO ( EXPAND -R HFMER\i386\lang\chs\%%I TEMP\ >NUL FOR /F %%I IN ('DIR/A-D/B TEMP') DO ( IF EXIST HFMER\%%I ( ECHO Processing i386\lang\chs\%%I XCOPY/DY HFMER\%%I TEMP\ >NUL&DEL/Q HFMER\%%I >NUL MAKECAB /D CompressionMemory=21 /D CompressionType=LZX TEMP\%%I /L HFMER\i386\lang\chs >NUL ) DEL/Q/S TEMP\%%I >NUL ) ) :: updating i386\lang\cht FOR /F %%I IN ('DIR/A-D/B HFMER\i386\lang\cht\*.*_') DO ( EXPAND -R HFMER\i386\lang\cht\%%I TEMP\ >NUL FOR /F %%I IN ('DIR/A-D/B TEMP') DO ( IF EXIST HFMER\%%I ( ECHO Processing i386\lang\cht\%%I XCOPY/DY HFMER\%%I TEMP\ >NUL&DEL/Q HFMER\%%I >NUL MAKECAB /D CompressionMemory=21 /D CompressionType=LZX TEMP\%%I /L HFMER\i386\lang\cht >NUL ) DEL/Q/S TEMP\%%I >NUL ) ) :: updating i386\lang\jpn FOR /F %%I IN ('DIR/A-D/B HFMER\i386\lang\jpn\*.*_') DO ( EXPAND -R HFMER\i386\lang\jpn\%%I TEMP\ >NUL FOR /F %%I IN ('DIR/A-D/B TEMP') DO ( IF EXIST HFMER\%%I ( ECHO Processing i386\lang\jpn\%%I XCOPY/DY HFMER\%%I TEMP\ >NUL&DEL/Q HFMER\%%I >NUL MAKECAB /D CompressionMemory=21 /D CompressionType=LZX TEMP\%%I /L HFMER\i386\lang\jpn >NUL ) DEL/Q/S TEMP\%%I >NUL ) ) :: updating i386\lang\kor FOR /F %%I IN ('DIR/A-D/B HFMER\i386\lang\kor\*.*_') DO ( EXPAND -R HFMER\i386\lang\kor\%%I TEMP\ >NUL FOR /F %%I IN ('DIR/A-D/B TEMP') DO ( IF EXIST HFMER\%%I ( ECHO Processing i386\lang\kor\%%I XCOPY/DY HFMER\%%I TEMP\ >NUL&DEL/Q HFMER\%%I >NUL MAKECAB /D CompressionMemory=21 /D CompressionType=LZX TEMP\%%I /L HFMER\i386\lang\kor >NUL ) DEL/Q/S TEMP\%%I >NUL ) ) :: updating i386\new FOR /F %%I IN ('DIR/A-D/B HFMER\i386\new\*.*_') DO ( EXPAND -R HFMER\i386\new\%%I TEMP\ >NUL FOR /F %%I IN ('DIR/A-D/B TEMP') DO ( IF EXIST HFMER\%%I ( ECHO Processing i386\new\%%I XCOPY/DY HFMER\%%I TEMP\ >NUL&DEL/Q HFMER\%%I >NUL MAKECAB /D CompressionMemory=21 /D CompressionType=LZX TEMP\%%I /L HFMER\i386\new >NUL ) DEL/Q/S TEMP\%%I >NUL ) ) :: updating i386\uniproc FOR /F %%I IN ('DIR/A-D/B HFMER\i386\uniproc\*.*_') DO ( EXPAND -R HFMER\i386\uniproc\%%I TEMP\ >NUL FOR /F %%I IN ('DIR/A-D/B TEMP') DO ( IF EXIST HFMER\uniproc\%%I ( ECHO Processing i386\uniproc\%%I XCOPY/DY HFMER\uniproc\%%I TEMP\ >NUL&DEL/Q HFMER\uniproc\%%I >NUL MAKECAB /D CompressionMemory=21 /D CompressionType=LZX TEMP\%%I /L HFMER\i386\uniproc >NUL ) DEL/Q/S TEMP\%%I >NUL ) ) :: cleaning HFMER (empty folders) RD/Q/S HFMER\uniproc >NUL RD/Q/S HFMER\WMS >NUL :: cleaning TEMP RD/Q/S TEMP >NUL :: COPYING NEW FILES STARTS HERE! REQUIRES EDITING UPDATE.INF / UPDATE.VER! SKIP IF CAN'T DO !!! :: moving new files to i386\sp6 ECHO.&ECHO.&ECHO Copying new files to i386\SP6...&ECHO. IF NOT EXIST HFMER\i386\sp6 MD HFMER\i386\sp6 FOR /F %%I IN ('DIR/A-D/B HFMER') DO ( ECHO Copying %%I XCOPY HFMER\%%I HFMER\i386\sp6 >NUL&DEL/Q HFMER\%%I >NUL ) :: moving HFMER\update\*.* to HFMER\i386\update\ IF EXIST HFMER\update\eula.txt MOVE/Y HFMER\update\eula.txt HFMER\i386\update\eula.txt IF EXIST HFMER\update\update.inf MOVE/Y HFMER\update\update.inf HFMER\i386\update\update-sp6.inf IF EXIST HFMER\update\update.ver MOVE/Y HFMER\update\update.ver HFMER\i386\update\update-sp6.ver :: copying catalogs from HFMER\update to HFMER\i386\svcpack ECHO.&ECHO.&ECHO Copying catalog files to Service Pack folder...&ECHO. IF EXIST HFMER\update\*.cat ( FOR /F %%I IN ('DIR/A-D/B HFMER\update\*.cat') DO ( IF NOT EXIST HFMER\i386\svcpack MD HFMER\i386\svcpack ECHO Copying %%I XCOPY HFMER\UPDATE\%%I HFMER\i386\svcpack\ >NUL&DEL/Q HFMER\UPDATE\%%I >NUL ) ) :: comparing SP6 folder with original W2K i386 ECHO.&ECHO.&ECHO Verifying new files...&ECHO. IF EXIST TEMP RD/Q/S TEMP MD TEMP\sp6 HFMER\i386\sp6\new XCOPY HFMER\i386\sp6\*.* TEMP\sp6 >NUL DEL/Q HFMER\i386\sp6\*.* >NUL :: sorting compressed files FOR /F %%I IN ('DIR/A-D/B W2KCD\i386\*.*_') DO ( EXPAND -R W2KCD\i386\%%I TEMP\ >NUL FOR /F %%I IN ('DIR/A-D/B TEMP') DO ( IF EXIST TEMP\sp6\%%I ( ECHO Processing %%I XCOPY/DY TEMP\%%I TEMP\sp6\ >NUL MAKECAB /D CompressionMemory=21 /D CompressionType=LZX TEMP\sp6\%%I /L HFMER\i386\sp6\ >NUL DEL/Q TEMP\sp6\%%I >NUL ) DEL/Q TEMP\%%I >NUL ) ) :: sorting non-compressed files FOR /F %%I IN ('DIR/A-D/B W2KCD\i386') DO ( FOR /F %%I IN ('DIR/B TEMP\sp6') DO ( IF EXIST W2KCD\i386\%%I ( ECHO Processing %%I XCOPY/DY W2KCD\i386\%%I TEMP\sp6\ >NUL ) XCOPY/DY TEMP\%%I HFMER\i386\sp6\%%I >NUL&DEL/Q TEMP\sp6\%%I ) ) XCOPY TEMP\sp6\*.* HFMER\i386\sp6\new\ >NUL :: cleaning TEMP RD/Q/S TEMP EXITThe 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 August 5, 2011 by tomasz86 Link to comment Share on other sites More sharing options...
tomasz86 Posted August 6, 2011 Author Share Posted August 6, 2011 (edited) I have a problem and don't know how to solve it.Why doesn't GOTO work here?splitinf.cmd update.infGOTO :SPThere is no problem if the first line is disabledREM splitinf.cmd update.infGOTO :SPThe script just does splitinf and stops... As far as I remember it worked before but now it doesn't There are no errors on the screen. It behaves as it there was EXIT after the splitinf line. Edited August 6, 2011 by tomasz86 Link to comment Share on other sites More sharing options...
bphlpt Posted August 6, 2011 Share Posted August 6, 2011 (edited) In a rush right now so don't have time to look up the syntax, but try executing the first line through a CALL statement. That should force return to execute the next line.Cheers and Regards Edited August 6, 2011 by bphlpt Link to comment Share on other sites More sharing options...
tomasz86 Posted August 6, 2011 Author Share Posted August 6, 2011 It works Link to comment Share on other sites More sharing options...
ricktendo Posted August 6, 2011 Share Posted August 6, 2011 (edited) INF UpdateInis is perfect for thisTell me the path+name the file I can give you some examplesUpdateIniFields[update-inifields-section-name]ini-file, ini-section, profile-name,(old-field), (new-field),(flags)Replaces, adds, and deletes fields in the value of a given INI entry. Unlike the Update INI File sectiontype, this type of section replaces, adds, or deletes portions of a value in an INI file entry rather than thewhole value. The section name, update-inifields-section-name, must appear in the UpdateIniFields itemin an Install section of the INF file.ini-fileName of the INI file containing the entry to change. For more information about specifying the INIfilename, see the topic that describes the Update INI File section type.ini-sectionName of the INI file section containing the entry to change.profile-nameName of the entry to change.old-fieldField value to delete.new-fieldField value to add, if not already there.flagsSpecifies whether to treat the old-field and new-field parameters as if they have a wild card character ornot and/or what separator character to use when appending a new field to an INI file entry. Can be anyof these values:Value Meaning0 (Default) Treat "*" character literally when matching fields, and not as a wild cardcharacter. Use blank (" ") as a separator when adding a new field to an entry.1 Treat "*" character as a wild card character when matching fields. Use blank (" ") as aseparator when adding a new field to an entry.2 Treat "*" character literally when matching fields, and not as a wild card character. Usecomma (",") as a separator when adding a new field to an entry.3 Treat "*" character as a wild card character when matching fields. Use comma (",") as aseparator when adding a new field to an entry.Any comments in the INI file line are removed as they might not be applicable after changes. Whenlooking for fields in the line in the INI file, spaces, tabs and commas are used as field delimiters.However, a space is used as the separator when the new field is appended to the line. Edited August 6, 2011 by ricktendo64 Link to comment Share on other sites More sharing options...
tomasz86 Posted August 8, 2011 Author Share Posted August 8, 2011 (edited) Thank you, ricktendo64. I'll check this tool for sure I've got another problem - for some it's probably very simple but I can't get over it...There is a directory which may be either empty or have some subdirectories inside.I doFOR /F %%I IN ('DIR/A-D/B DIRECTORY') DO (and get "file not found" output when there are no files inside. Is there any way to prevent it from being displayed? Normally it's justDIR/A-D/B DIRECTORY >NULbut here I don't know where to put >NUL.The other problem is that I wont to doIF NOT EXIST DIRECTORY\*.* (but subdirectories are also treated as *.*. Is there a simple way to check if there are no files (excluding subdirs) in a directory? Edited August 8, 2011 by tomasz86 Link to comment Share on other sites More sharing options...
jaclaz Posted August 8, 2011 Share Posted August 8, 2011 Is there any way to prevent it from being displayed? Normally it's justLearn about "Standard Output" and "Standard Error" and their redirection:http://www.robvanderwoude.com/redirection.php(already given to you)AND:http://www.robvanderwoude.com/battech_redirection.phpjaclaz Link to comment Share on other sites More sharing options...
tomasz86 Posted August 9, 2011 Author Share Posted August 9, 2011 (edited) I read these explanations and still don't know where I should put >NUL in this script: FOR /F %%I IN ('DIR/A-D/B HFMER') DO ( ECHO Copying %%I MOVE HFMER\%%I %SP6%\sp6 >NUL )The "file not found" error is displayed when there are no files in HFMER.Tell me the path+name the file I can give you some examplesThe file path is %SP6UPD%\update.inf. Edited August 9, 2011 by tomasz86 Link to comment Share on other sites More sharing options...
jaclaz Posted August 9, 2011 Share Posted August 9, 2011 I read these explanations and still don't know where I should put >NUL in this script:You didn't read them "hard enough". FORGET about your current project.Create a new batch file with ONLY these commands, as CLEARLY stated on the given page:http://www.robvanderwoude.com/battech_redirection.php@ECHO OFFECHO This text goes to Standard OutputECHO This text goes to Standard Error 1>&2ECHO This text goes to the Console>CONand test it as explained there.Then try with:@ECHO OFFFOR /F %%I IN ('DIR/A-D/B HFMER') DO (ECHO Copying %%IECHO No redirection:MOVE HFMER\%%I %SP6%\sp6ECHO.ECHO Redirection of DEFAULT "Standard output" to NUL:MOVE HFMER\%%I %SP6%\sp6 >NULECHO.ECHO EXPLICIT redirection of "Standard output" to NUL:MOVE HFMER\%%I %SP6%\sp6 1>NULECHO.ECHO EXPLICIT redirection of "Standard Error" to NUL:MOVE HFMER\%%I %SP6%\sp6 2>NULECHO.ECHO EXPLICIT redirection of BOTH "Standard output" "Standard Error" to NUL:MOVE HFMER\%%I %SP6%\sp6 2>&1>NUL )jaclaz Link to comment Share on other sites More sharing options...
tomasz86 Posted August 10, 2011 Author Share Posted August 10, 2011 (edited) It still doesn't work... the problem is that I want to redirect this('DIR/A-D/B HFMER')to >NUL, not the rest which is afterDO (The script stops after doing DIR if the directory is empty ("File Not Found"). Edited August 10, 2011 by tomasz86 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now