Bilou_Gateux Posted October 31, 2005 Share Posted October 31, 2005 (edited) I have parsed with HIVEUPD.CMD some lines from a lot of KB######.INF files of Microsoft Critical updates and output the result in two files: HIVESFT.TXT and HIVECLS.TXTi would like to insert hivesft.txt into %source%\i386\HIVESFT.INF at end of [AddReg] section:just before next section called [AddReg.Upgrade]i would like to insert hivecls.txt into %source%\i386\HIVECLS.INF at end of [AddReg] section:just before next section called [DelReg]could it be done with a batch? Edited February 12, 2006 by Bilou_Gateux Link to comment Share on other sites More sharing options...
Yzöwl Posted October 31, 2005 Share Posted October 31, 2005 Yes it can be done with a batch file and no third party utilities, however it will not necessarily be quick, and the coding isn't nice.The ideal tool would be SED or AWK (GAWK), both of which should be available here, for your pupose, however can you not use Fedit, (search the forum for it). Link to comment Share on other sites More sharing options...
Bilou_Gateux Posted November 1, 2005 Author Share Posted November 1, 2005 (edited) Doing it with FEdit is too complex:Editing text file from batch file I have already used SED for appending lines to an existing inf as posted herein this old archived post, i was adding new lines one by one.SED allows to insert a block of lines before defined pattern with one command:for updating HIVESFT.INF, i will add this 1st line to HIVESFT.TXT: /[AddReg.Upgrade]/ ifor updating HIVECLS.INF, i will add this 1st line to HIVECLS.TXT: /[DelReg]/ iadd backslash \ at end of each line to be inserted (including the 1st).special metacharacters like backslash \ or quote " need to be escaped with an added backslash \left [ and right ] square brackets are escaped with an added backslash \Finally i will use gsar.exe which is exactly the needed tool.:// use charmap to find character hex code:// search 'reverse solidus' and escape with 'reverse solidus'gsar -s:x5c -r:x5c:x5c -o temp\hivecls.txt:// search 'quotation mark' and escape with 'reverse solidus'gsar -s:x22 -r:x5c:x22 -o temp\hivecls.txt:// search 'carriage return' and add 'reverse solidus' beforegsar -s:x0d -r:x5c:x0d -o temp\hivecls.txt:// search 4 blanks & 'Capital Letter H' and keep only 'Capital Letter H'gsar -s:x20:x20:x20:x20:x48 -r:x48 -o temp\hivecls.txt:// Header:// search 'left square bracket' and escape with 'reverse solidus'gsar -s:x5b -r:x5c:x5b -o temp\hivecls.txt:// search 'right square bracket' and escape with 'reverse solidus'gsar -s:x5d -r:x5c:x5d -o temp\hivecls.txt:// sed don't support direct alteration of input files so output to intermediate filesed -f temp\hivecls.txt i386\hivecls.inf >temp\hivecls.int:// replace original hivecls.inf with intermediate file hivecls.intcopy /y temp\hivecls.int i386\hivecls.inf Edited February 12, 2006 by Bilou_Gateux Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now