We help IT Professionals succeed at work.

VB App under Win2000 Terminal Services

finster asked
Last Modified: 2010-05-01
My application is being used under Terminal Services (TS) on a Win2000 server.  It reads some initial settings from an .ini file, which resides in the \WINDOWS or \WINNT directory (depending on the OS).  However, in some circumstances, users logiing in from one area need different settings in the .ini file whereas other users may need another set.  

Talking to the tech guy who administers the servers at the client's office, it appears that when the ini file is placed on the server's windows path, the program runs ok, until the second set of different users wants to use it, and then they would overwrite the original settings.  

It appears as though if the ini file is placed into the windows directory for the profile settings of the logged in user, the program, using a GetPrivateProfileString API call, looks towards the server's windows directory rather than the logged in user's profile windows directory.

Is there something we have missed?  I want to be able to provide a different ini file for each user.

Any help is greatfully appreciated.
Watch Question

Usually the account's info is stored in the C:\Documents and Settings\ folder you should put the ini files under the directories under that folder. There is a folder under C:\Documents and Settings\ for each user.
You can easily get the path to the users directory with

Private Declare Function ExpandEnvironmentStrings Lib "kernel32" Alias "ExpandEnvironmentStringsA" (ByVal lpSrc As String, ByVal lpDst As String, ByVal nSize As Long) As Long

    Dim buffer As String * 255
    ExpandEnvironmentStrings "%UserProfile%", buffer, 255
    MsgBox "User Profile: " & buffer

You can also get

The remainder are only available to interactive applications. HOMEDRIVE HOMEPATH


All this is useful, but doesn't explain the root of the problem ie why does my app find the ini in the machine's windows directory rather than the user's profile windows directory?

I'm using GetPrivateProfileString to read the ini file
This one is on us!
(Get your first solution completely free - no credit card required)

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.