Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Possible to write .ini from .bat?

Possible to write .ini from .bat?

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    blueSprite
    wrote on last edited by
    #1

    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

    J P B 3 Replies Last reply
    0
    • B 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

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      You can use echo.For instance, the following commands

      echo>parms.ini [general]
      echo>>parms.ini key=value

      create an .INI file like this

      [general]
      key=value

      Note 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[^]!

      1 Reply Last reply
      0
      • B 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

        P Offline
        P Offline
        pbloechl
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • B 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

          B Offline
          B Offline
          blueSprite
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups