How do you determine Windows directory

  • Thread starter Thread starter Richard L Rosenheim
  • Start date Start date
R

Richard L Rosenheim

Is there a method in the .NET Framework that returns the path to just the
Windows directory?

The closest I've been able to find is System.Environment.SystemDirectory.
On my machine, it returns "C:\Windows\System32". What I'm looking for in
this case is "C:\Windows".

TIA,

Richard Rosenheim
 
Hi there... You can get what you want like this...

Aproach 1
********
MsgBox(System.Environment.GetEnvironmentVariable("Windir"))

Aproach 2
********
Dim winfolder As String =
CType(System.Environment.GetFolderPath(Environment.SpecialFolder.System).Split("\"),
String())(0) + "\" +
CType(System.Environment.GetFolderPath(Environment.SpecialFolder.System).Split("\"),
String())(1)

MsgBox(winfolder)

Regards,
 
Richard L Rosenheim said:
Is there a method in the .NET Framework that returns the path to just the
Windows directory?

Windows directory:

'System.Environment.GetEnvironmentVariable("WinDir")'
'System.Environment.ExpandEnvironmentVariables("%WinDir%")'

- or -

Trick by Bill McCarthy:

'System.Environment.GetFolderPath(CType(&H24,
System.Environment.SpecialFolder))'

- or -

P/invoke on 'GetWindowsDirectory':

<URL:http://groups.google.de/groups?selm=#pJhic2CBHA.2200@tkmsftngp07>
 
Thanks everyone -- the first approach is what I was looking for. Completely
forgot about the environment variables...

Richard Rosenheim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top