0

We have an application that depends on the .NET framework and performs a check at startup to see if the framework is installed. On our client machines, this works fine, but on our servers that run Windows Server 2k3, the check fails. When we look at the environment variables, it correctly shows that the Windows directory is C:\Windows and we can see that .NET is correctly installed there, but the Windows API call (GetWindowsDirectory) from our application returns C:\Programs and Settings\[User Name]\Windows which is invalid and doesn't even exist. Is there something about Server 2k3 that would cause this kind of mis-reporting, or do I need to look elsewhere? Thanks.

Tom A
  • 218
  • 1
  • 3
  • 10

1 Answers1

1

You're better off reading from the SystemRoot environment variable instead of using the Windows API call. Try string WindowsDir = System.Environment.GetEnvironmentVariable ("SystemRoot"); and see how you get on with it.

If you're calling from native code char *WindowsDir = getenv ("SystemRoot"); is what you want.

Maximus Minimus
  • 8,987
  • 2
  • 23
  • 36
  • This lets me return exactly what I want. The strange thing about my problem though is it was only happening when I was working with the servers through Remote Desktop. Connecting to them locally returns the correct values with my original method. – Tom A Mar 04 '10 at 00:14