View Full Version : Can I use a special folder as part of a value in creating an INI File?
NewsArchive
05-14-2010, 01:26 AM
Can I use a "Common Documents" as part of a value in creating an INI File?
I want it to expand to "C:\Users\Public\Documents" in windows 7 and the
other for Vista...
Do I need to "write it" separately from the regular INI file creating
process?
...
Paul Macfarlane
NewsArchive
05-14-2010, 02:40 AM
Paul,
> Can I use a "Common Documents" as part of a value in creating an INI File?
>
> I want it to expand to "C:\Users\Public\Documents" in windows 7 and the
> other for Vista...
>
> Do I need to "write it" separately from the regular INI file creating
> process?
The INI format supported in the "Edit INI..." Contents field is:
[section]
keyname=value
So you can do this:
[section]
keyname=%_CSIDL_COMMON_DOCUMENTS%
--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910
SetupBuilder is Windows 7 installation -- "point. click. ship"
-- Official Comodo Code Signing and SSL Certificate Partner
NewsArchive
05-14-2010, 02:41 AM
I assume that means I can do:
[section]
keyname=%_CSIDL_COMMON_DOCUMENTS%\MyAppdata\
Thanks !
Paul Macfarlane
NewsArchive
05-14-2010, 02:41 AM
Hi Paul,
> I assume that means I can do:
>
> [section]
> keyname=%_CSIDL_COMMON_DOCUMENTS%\MyAppdata\
Yes, no problem!
Friedrich
NewsArchive
05-17-2010, 02:11 AM
Friedrich,
As a followup....
The INI file is only done for Vista/Win7, but I do not want to modify it
if it already exists on the users system.
The problem is it says "Always Install" and there is not option to only
install if it doesn't exist.
I thought about just installing a INI I create as a regular file, but
then I can't expand the Common_Documents....
Thoughts?
Thanks,
Paul
NewsArchive
05-17-2010, 02:12 AM
Paul,
> As a followup....
>
> The INI file is only done for Vista/Win7, but I do not want to modify
> it if it already exists on the users system.
> The problem is it says "Always Install" and there is not option to only
> install if it doesn't exist.
>
> I thought about just installing a INI I create as a regular file, but then
> I can't expand the Common_Documents....
>
> Thoughts?
"Always Install" refers to the "Feature". It is not related to whether the
file exists or not.
Just add a "If File/Folder exists..." statement around your INI command and
you are done.
Does this help?
Friedrich
NewsArchive
05-17-2010, 02:12 AM
Paul,
Did you consider having your program create the ini file instead of having
the SB installer do it? You can put logic in your program's init section to
check if the file exists, and set the path for the ini file. You already
need to set the ini file path in your app anyway so that it points to the
right location.
--
Regards,
Abe Jimenez
Clarion 7.1.7118 EE
Windows 7 Pro 64 Bit
NewsArchive
05-17-2010, 02:13 AM
The issue would be execution level. I don't want to have the normal
execution elevated. Only during install....
Paul Macfarlane
NewsArchive
05-17-2010, 02:14 AM
You don't need to be elevated to create an ini file in common documents
Abe Jimenez
NewsArchive
05-17-2010, 02:15 AM
BTW, it would like this (see attached screenshot).
Friedrich
NewsArchive
05-17-2010, 02:15 AM
Yes - thanks !
Paul Macfarlane
NewsArchive
05-18-2010, 01:50 AM
No, but the INI is in the program folder to tell the application where
the data is.
That way the user can set the common documents folder or some network
location.
It's only read by invoker applications..
This way my app can be installed on Win98, 2000, XP, Vista, Win7 2003,
2008, etc. and it behaves as expected for the platform.
Paul Macfarlane
NewsArchive
05-18-2010, 02:04 AM
In a similar vein, for one app I store the data location in the HKLM portion
of the registry.
That way, it also works if the program resides on a USB or flash drive
because it will read the correct data location for that machine regardless
of the folder in which the app resides.
The app has a shellExecute - run asAdministrator helper app if the user
wants to modify the data location.
jf
NewsArchive
05-18-2010, 02:09 AM
Paul,
Here is what I understood you were trying to do.
1. If you are installing a new customer, you want to use an allowed folder
(CSIDL). It doesn't matter what the OS, you want to put the INI file
somewhere that MS says is OK
2. If you are installing to a customer that that already has an old version
of the app (maybe running in an older version of the OS, it doesn't really
matter) you want to continue to use the old ini file which already exists.
3. Now that you have the ini file (new or old and it doesn't matter what OS)
it tells you where the data is.
You need this INI file location in your program at runtime when you want to
access the DB, not when the program is being installed. So you need to find
the CSIDL location using propath, winevent or SV's new feature in C7.1.
You will need IF EXISTS to determine if the INI file already exists.
Nothing in SB.
My recommendation if that if you find the existing INI file in a location
that is no longer allowed by windows, you move it to a valid location and
forget about the old location. Just use the allowed location for new or old
installs. If the INI file doesn't exist (new install) use the valid
location.
If I have your objectives all wrong, I apologize, please forget about his
post.
Regards,
--
Regards,
Abe Jimenez
Clarion 7.1.7118 EE
Windows 7 Pro 64 Bit
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.