%USERPROFILE% working Bad

  • Thread starter Thread starter Ray at
  • Start date Start date
R

Ray at

Please don't multipost. Follow up in the first group to which you posted
this message.

Ray at work
 
Hello,
I have a Program that uses by default a .ini file inside this program
directory. But if i want to run personally , for each user , to catch his
personal profiles, like temp directories , etc.. i need to put that .ini
file inside Documents and Settings\%USERNAME%\Windows.

The problem is :
For some users, it works and for other users, it doesn´t works. When it
doesnt work the program uses the default .ini file, causing me conflict of
temp files created by the program when the user run it.
I realized that the %HOMEPATH% for that " working good" users is like:
c:\Documents and settings\%USERNAME% and for the others it is blank. Another
thing i realized is that when i logon with a "working good" user that folder
(%USERPROFILE%\WINDOWS) is automatically created and for the others dont.

There is a way to configure or to correct that specificattions for this
"working bad " users?

Thanks
Leonardo
 
In said:
Hello,
I have a Program that uses by default a .ini file inside this
program directory. But if i want to run personally , for each user
, to catch his personal profiles, like temp directories , etc.. i
need to put that .ini file inside Documents and
Settings\%USERNAME%\Windows.

The problem is :
For some users, it works and for other users, it doesn´t works.
When it doesnt work the program uses the default .ini file,
causing me conflict of temp files created by the program when the
user run it. I realized that the %HOMEPATH% for that " working
good" users is like: c:\Documents and settings\%USERNAME% and for
the others it is blank. Another thing i realized is that when i
logon with a "working good" user that folder
(%USERPROFILE%\WINDOWS) is automatically created and for the
others dont.

There is a way to configure or to correct that specificattions for
this "working bad " users?

All I have are suggestions.
Don't use %homepath% (this is not always reliable)
Do use %userprofile%
and %temp% (in most cases %temp% under a given account/profile
will be both correct and read/writable by that account. (but you
should probably test/handle that as well).
Use "%userprofile%\Application Data\<Your_app_name>" (this is the way
it is "supposed" to be done).
You should probably test for existence of the directory or file and
if not found trap the error and handle it. If needed, attempt to
create the directory and test for success/fail and handle that as
well. I would not rely on "is automatically created" at all.

Good programming practice should not make assumptions about existence
or access and everywhere you rely on "I can assume this works" you
should really be confirming it "for sure".

I assume you specifically do not want to use the registry (HKCU) to
store settings and that is the reason for INI files.
 
Back
Top