Page 1 of 1

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

Posted: 01 Mar 2020 02:14
by Cc4Dayz
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

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

Posted: 01 Mar 2020 05:34
by aGerman
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

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

Posted: 01 Mar 2020 06:03
by Cc4Dayz
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

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

Posted: 01 Mar 2020 06:38
by aGerman
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

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

Posted: 09 Apr 2020 11:36
by warlock666999
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