Hi there
This forum has been a real help, I had to create a really complicated batch file that would search for and add specific lines of text within the firewall.ini of Blackice on W2K and XP machines, then make a bunch of registry mods on XP machines only, and then prompt the user to either accept or undo those changes...whew...
The problem I'm having is that there is a line of text I need to add to the firewall.ini file under TCP settings, that also pre-exists under a UDP heading. The dilemna is that when I ask the batch to check for the new line before adding it, and exit the called batch if it finds it, it will always find the one under the UDP settings and it exits without adding the line to the file. My work around is crude, I just have it add the line anyway...problem is every time this batch is run, it will add another instance of that line into the file...
For Example I want to add the text "ACCEPT, 1024 - 65535" below a heading to make it look like this...
[MANUAL OUTBOUND TCP HIGH ACCEPT]
ACCEPT, 1024 - 65535
But...This line also exists elsewhere in the ini file like this
[MANUAL UDP HIGH ACCEPT]
ACCEPT, 1024 - 65535
The current code I have for this portion is this...
:Addtxt5
For /F "eol= tokens=* delims= " %%A in (%1) Do (
Echo %%A>> %1.tmp
If "%%A"=="ACCEPT, 1024 - 65535" (
Goto Nupd5)
If "%%A"=="[MANUAL OUTBOUND TCP high ACCEPT]" (
Echo ACCEPT, 1024 - 65535>> %1.tmp))
Move %1.tmp %1
Exit /b
You can see that it looks first so that the line isn't added a second time, but since the line exists under the "[MANUAL UDP high ACCEPT]" heading the 'Goto' cmd sends it on to the :Nupd5 section and exits.
Is there any way within the 'IF' statement I've provided to have it look for two lines of text that follow each other, for example, have it look for these two lines in this order
[MANUAL OUTBOUND TCP high ACCEPT]
ACCEPT, 1024 - 65535
And then Goto Nupd5 should it find them, or continue on with the script should it not find them.
Sorry for the long post...I just wanted it to be clear.
Thanks