View Full Version : Reading from ini to find a path
Here is the scenario:
I want to find a directory and store it to a variable.
The directory is written in an ini file wich is stored in the window directory.
I find the file with %Windir%\myini.ini
The ini file contains this:
[Program]
Programdir=c:\directory\program
Is there a way to get "c:\directory\program" saved as a variable, skipping the Programdir= part of the line?
Thanks
How about instead of an .ini file, save your path info as a text file, you can use whatever extension you want i.e %Windir%\MyFile.ext
then use the Text File actions to read from and write to it.
Good idea, thanks.
I'll try this:
1. Rename the ini file to txt
2. Read the txt file
3. Rename the txt file to ini again
Sure, you can do that, but I question the need. re you using th% .ini fil% to hold other data? Are you aware that text files do not have to have the .txt extension? You can give it any extension you want. You can even give it the .ini extension if you want, and just use the text file actions instead of the .ini file actions. Heck, for that matter you can call it
my_secret_text_file.paal
The read and write text file actions will still work fine.
csd214
01-21-2004, 10:18 AM
Hi guys,
why do a simple issue difficult?
Use the action “Read from INI-file”
and enter:
Filename %Windir%\myini.ini
Section Program
Value name Programdir
In fact Setup Factory is very clever to create, modify and read INI-files. I have projects where I have used an INI-file as a parameter file to the setup (Silent Install). A structured INI-file is much simpler to use than an ordinary text file!
Yes, I agree that Setup Factory does a splendid job with .ini files. I use .ini files extensively in my own projects. Original question:
Originally posted by Paal
Is there a way to get "c:\directory\program" saved as a variable, skipping the Programdir= part of the line?
Perhaps I’m missing something here, but I understood the question as, how to save and read the data without having the “Programdir=” part, just the data path. Why would a person want to do it this way? I don’t know, I didn’t ask. I just tried to come up with a solution that would answer the question, given what I understood the question to be. If we are talking about a data file that contains a single line of data, then I don’t understand how using Text File Actions to read and write the data, is any more difficult than using INI File read and write actions.
I’m just a Script Kitty, not a real programmer, and certainly not an expert with any of IR’s great tools. I’m sure that there are other ways, perhaps even easier ways to answer this question, but given my understanding of the original question’s specs, I can’t think of an easier way.
:)
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.