Update text file batch file

R

Richhall

Hi

I have an application on a number of users workstations on the
network, and want to amend an entry in a text file e.g config.ini on
all workstations. Can i connect using a batch to delete a line and add
a line or find text and change it within a file if I know all the IP
addresses?

i.e

[parameter 1] Item=Y
[parameter 1] Item=N
[parameter 1] Item=Y
[parameter 1] Item=N
[parameter 1] DNS=test.systems.co.uk

i want to change to:

[parameter 1] Item=Y
[parameter 1] Item=N
[parameter 1] Item=Y
[parameter 1] Item=N
[parameter 1] DNS=test2.systems.co.uk

Cheers

Rich
 
P

Pegasus \(MVP\)

Richhall said:
Hi

I have an application on a number of users workstations on the
network, and want to amend an entry in a text file e.g config.ini on
all workstations. Can i connect using a batch to delete a line and add
a line or find text and change it within a file if I know all the IP
addresses?

i.e

[parameter 1] Item=Y
[parameter 1] Item=N
[parameter 1] Item=Y
[parameter 1] Item=N
[parameter 1] DNS=test.systems.co.uk

i want to change to:

[parameter 1] Item=Y
[parameter 1] Item=N
[parameter 1] Item=Y
[parameter 1] Item=N
[parameter 1] DNS=test2.systems.co.uk

Cheers

Rich

You could do it with this batch file:
@echo off
set Source=\\192.168.1.10\c$\Some Folder\Some File.txt
type "%Source%" | find /i /v "DNS=" > "%temp%\temp.txt"
copy /y "%temp%\temp.txt" "%Source%" > nul
echo [parameter 1] DNS=test2.systems.co.uk >> "%Source%"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top