Quantcast

Jump to content

» «
Photo

Writing a batch file to amend .ini

2 replies to this topic
Raindancer
  • Raindancer

    Beer monster

  • Feroci
  • Joined: 12 Nov 2001
  • None

#1

Posted 01 February 2016 - 01:12 PM

OK so I need to write a batch file to carry out some commands on a remote computer and not sure the best way to do it.  I need to edit an ini file  on one line but leave the other 13 lines intact with no changes. 

 

I need to edit line 2

SCHEME=3|10|0|0|

 

and leave the rest of the text 

 

 

PrintPause=00
SCHEME=3|10|0|0|
TL_IP=xxxx|TL_PORT=xxxx|
ULOG_IP=xxxx|ULOG_PORT=xxxx|
UDP_PORT=xxxx|
TimeFromServer|TIME_PORT=xxxx|
xxxx_COMPORT=COM5|
xxxx_COMPORT=COM3|
DeclineReInitTran|
VolumeControl|
GPS_COMPORT=COM6|
MediaUDP_IP=xxxxxxxx|
MediaUDP_Port=xxxxxx|
 
Is anyone able to help me please :)

 dice
  •  dice

    Always rolling

  • The Yardies
  • Joined: 12 Aug 2008
  • None
  • Best Server SAMP 2009

#2

Posted 01 February 2016 - 06:33 PM Edited by dice, 01 February 2016 - 06:48 PM.

The simplest way would reading the whole file, comparing lines and writing a new file, then cleaning up.

Something like
Spoiler


If you're planning on creating more complex scripts I'd advise using PowerShell (or maybe vbScript) for their general simplicity, being build around .Net, and easy access to object models like WMI or COM
  • trip likes this

trip
  • trip

    ~

  • Andolini Mafia Family
  • Joined: 10 Oct 2007
  • United-States
  • Contribution Award [GTAF]
    Contribution Award [Gen Chat]
    Contribution Award [GTAF Census]
    Doggo-Chop Winner 2016

#3

Posted 02 February 2016 - 09:58 PM

Are you executing the batch/process from the remote machine? I sure hope so.


Dice has the same recommendation I would have...If it is win based.

If we are doing unix the approache is the same except you will be doing it in bash, korn, or perl.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users