Possible to write .ini from .bat?
-
OS: win 2000 Is it possible to write to the .ini file from a .bat file? Here's what I'm trying to do: I have .bat that is supposed to make the user's life easy by installing our software using a base directory that the user specifies. So the user would execute "installProd.bat C:\user_area" (or Whatever Disk>:\where ever). The .bat creates the directory specifed (as well as others below it) places our C++ executables and our supporting files (like any input data files or help files, etc) into the dirs. Now I'm hoping to write to the .ini file from within the .bat so I can put the user defined base directory into the .ini. Then when the C++ executables run, the executables can access the .ini file for the base directory path (using GetPrivateProfileSettings or GetProfileString etc). Is it possible? Or am I going down the wrong path for this? ANy suggestions and guidance is much appreciated! Thanks, :rose:blueSprite
-
OS: win 2000 Is it possible to write to the .ini file from a .bat file? Here's what I'm trying to do: I have .bat that is supposed to make the user's life easy by installing our software using a base directory that the user specifies. So the user would execute "installProd.bat C:\user_area" (or Whatever Disk>:\where ever). The .bat creates the directory specifed (as well as others below it) places our C++ executables and our supporting files (like any input data files or help files, etc) into the dirs. Now I'm hoping to write to the .ini file from within the .bat so I can put the user defined base directory into the .ini. Then when the C++ executables run, the executables can access the .ini file for the base directory path (using GetPrivateProfileSettings or GetProfileString etc). Is it possible? Or am I going down the wrong path for this? ANy suggestions and guidance is much appreciated! Thanks, :rose:blueSprite
You can use
echo
.For instance, the following commandsecho>parms.ini [general]
echo>>parms.ini key=valuecreate an .INI file like this
[general]
key=valueNote that a single
>
means "create new file" and>>
means "append". Hope this helps. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo Want a Boost forum in Code Project? Vote here[^]! -
OS: win 2000 Is it possible to write to the .ini file from a .bat file? Here's what I'm trying to do: I have .bat that is supposed to make the user's life easy by installing our software using a base directory that the user specifies. So the user would execute "installProd.bat C:\user_area" (or Whatever Disk>:\where ever). The .bat creates the directory specifed (as well as others below it) places our C++ executables and our supporting files (like any input data files or help files, etc) into the dirs. Now I'm hoping to write to the .ini file from within the .bat so I can put the user defined base directory into the .ini. Then when the C++ executables run, the executables can access the .ini file for the base directory path (using GetPrivateProfileSettings or GetProfileString etc). Is it possible? Or am I going down the wrong path for this? ANy suggestions and guidance is much appreciated! Thanks, :rose:blueSprite
why not use an installer ? InnoSetup (http://www.jrsoftware.org/isinfo.php) provides a simple tool for creating setup's. It has also builtin support for writing in .ini file. The Tool is free available and well supported If you still want to handle the stuff with a batch script: append your stuff at the end of that ini-file via ... echo [section] >> myIniFile.ini echo myKey=%1 >> myIniFile.ini ... pbloechl
-
OS: win 2000 Is it possible to write to the .ini file from a .bat file? Here's what I'm trying to do: I have .bat that is supposed to make the user's life easy by installing our software using a base directory that the user specifies. So the user would execute "installProd.bat C:\user_area" (or Whatever Disk>:\where ever). The .bat creates the directory specifed (as well as others below it) places our C++ executables and our supporting files (like any input data files or help files, etc) into the dirs. Now I'm hoping to write to the .ini file from within the .bat so I can put the user defined base directory into the .ini. Then when the C++ executables run, the executables can access the .ini file for the base directory path (using GetPrivateProfileSettings or GetProfileString etc). Is it possible? Or am I going down the wrong path for this? ANy suggestions and guidance is much appreciated! Thanks, :rose:blueSprite
Thanks both of you for your responses. I completely overlooked the obvious. BTW, the installer suggestion is a great one, but my company often refuses to use anyone else's software but their own (the wheel has been reinvented more times than I can count ;) Thank you both so much for your responses! :rose:blueSprite:-D