Help | Hey can some one help me to eddit a .ini file automatic from cmd

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Cc4Dayz
Posts: 2
Joined: 01 Mar 2020 02:03

Help | Hey can some one help me to eddit a .ini file automatic from cmd

#1 Post by Cc4Dayz » 01 Mar 2020 02:14

Hey can some one help me to make a .ini file automatic from cmd with input.
I want to make a bat file that will let me put input in middle of the text for example :

Code: Select all

echo Please enter IP
Set /P X=
Computer IP=%X%
echo Please enter Port
Set /P M=
Port = %M%
and save it as "test.ini" file.
//in the "test.ini" file text that saved

Code: Select all

Computer IP=192.168.1.1
Port = 55555
Thank you for the help hope it`s possible and understandable haha :D
Last edited by aGerman on 01 Mar 2020 05:27, edited 1 time in total.

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Help | Hey can some one help me to eddit a .ini file automatic from cmd

#2 Post by aGerman » 01 Mar 2020 05:34

Just use ECHO redirection. The operators > and >> both create a new file if it doesn't exist. But while > overwrites an existing file, >> appends to it.
So, the piece of code to write your ini file could either look like that

Code: Select all

>"test.ini" echo Computer IP=%X%
>>"test.ini" echo Port=%M%
or

Code: Select all

>"test.ini" (
  echo Computer IP=%X%
  echo Port=%M%
)
FWIW You should really use more descriptive variable names here.

Steffen

Cc4Dayz
Posts: 2
Joined: 01 Mar 2020 02:03

Re: Help | Hey can some one help me to eddit a .ini file automatic from cmd

#3 Post by Cc4Dayz » 01 Mar 2020 06:03

Hey, Thank you for your help, but it still don`t work for me

Code: Select all

cls
	echo Type the Port number then press enter:
	Set /P A=
	echo Type the IP number then press enter:
	Set /P B=
Echo on
CD /d K:\Batch 4\AIPA1\Settings\test
copy con Net.ini 
>"Net.ini" ([General]
>>	xxxx =xx \\text
>>	xxxx =xx \\text
>>	xxxx =xx \\text
>>	xxxx =xx \\text
>>	Local Send Port = %A%
>>	Computer IP=%B%
pause

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Help | Hey can some one help me to eddit a .ini file automatic from cmd

#4 Post by aGerman » 01 Mar 2020 06:38

Your code has nothing to do with what I told you. ECHO redirection means that you need the ECHO command. Carefully read and try again.

Steffen

warlock666999
Posts: 4
Joined: 09 Apr 2020 11:05

Re: Help | Hey can some one help me to eddit a .ini file automatic from cmd

#5 Post by warlock666999 » 09 Apr 2020 11:36

Maybe this might help

Code: Select all

@echo off
cd /d %~dp0
set /p ip= Please enter IP:
set /p port= Please enter Port:
(
echo computer IP=%ip%
echo Port = %port%
) >Test.ini
echo All Done File Saved in root of this batch file
pause

Post Reply