By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,886 Members | 1,123 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,886 IT Pros & Developers. It's quick & easy.

How do you determine Windows directory

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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,
--
Angel J. Hernández M.
MCP - MCAD - MCSD - MCDBA
http://groups.msn.com/desarrolladoresmiranda
http://ajhsis.net
"Richard L Rosenheim" <ri*****@rlr.com> escribió en el mensaje
news:OQ**************@tk2msftngp13.phx.gbl...
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

Nov 21 '05 #2

P: n/a
"Richard L Rosenheim" <ri*****@rlr.com> schrieb:
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("%W inDir%")'

- 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=%23pJhic2CBHA.2200%40tkmsftngp07>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3

P: n/a
Thanks everyone -- the first approach is what I was looking for. Completely
forgot about the environment variables...

Richard Rosenheim
"Angel J. Hernández M." <an**********@hotmail.com> wrote in message
news:e7**************@TK2MSFTNGP11.phx.gbl...
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).Spl
it("\"), String())(0) + "\" +
CType(System.Environment.GetFolderPath(Environment .SpecialFolder.System).Spl
it("\"), String())(1)

MsgBox(winfolder)

Regards,
--
Angel J. Hernández M.
MCP - MCAD - MCSD - MCDBA
http://groups.msn.com/desarrolladoresmiranda
http://ajhsis.net
"Richard L Rosenheim" <ri*****@rlr.com> escribió en el mensaje
news:OQ**************@tk2msftngp13.phx.gbl...
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


Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.