473,672 Members | 2,577 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do you determine Windows directory

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.Environm ent.SystemDirec tory.
On my machine, it returns "C:\Windows\Sys tem32". What I'm looking for in
this case is "C:\Windows ".

TIA,

Richard Rosenheim
Nov 21 '05 #1
3 1710
Hi there... You can get what you want like this...

Aproach 1
********
MsgBox(System.E nvironment.GetE nvironmentVaria ble("Windir"))

Aproach 2
********
Dim winfolder As String =
CType(System.En vironment.GetFo lderPath(Enviro nment.SpecialFo lder.System).Sp lit("\"),
String())(0) + "\" +
CType(System.En vironment.GetFo lderPath(Enviro nment.SpecialFo lder.System).Sp lit("\"),
String())(1)

MsgBox(winfolde r)

Regards,
--
Angel J. Hernández M.
MCP - MCAD - MCSD - MCDBA
http://groups.msn.com/desarrolladoresmiranda
http://ajhsis.net
"Richard L Rosenheim" <ri*****@rlr.co m> escribió en el mensaje
news:OQ******** ******@tk2msftn gp13.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.Environm ent.SystemDirec tory.
On my machine, it returns "C:\Windows\Sys tem32". What I'm looking for in
this case is "C:\Windows ".

TIA,

Richard Rosenheim

Nov 21 '05 #2
"Richard L Rosenheim" <ri*****@rlr.co m> schrieb:
Is there a method in the .NET Framework that returns the path to just the
Windows directory?


Windows directory:

'System.Environ ment.GetEnviron mentVariable("W inDir")'
'System.Environ ment.ExpandEnvi ronmentVariable s("%WinDir%") '

- or -

Trick by Bill McCarthy:

'System.Environ ment.GetFolderP ath(CType(&H24,
System.Environm ent.SpecialFold er))'

- or -

P/invoke on 'GetWindowsDire ctory':

<URL:http://groups.google.d e/groups?selm=%23 pJhic2CBHA.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
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**********@h otmail.com> wrote in message
news:e7******** ******@TK2MSFTN GP11.phx.gbl...
Hi there... You can get what you want like this...

Aproach 1
********
MsgBox(System.E nvironment.GetE nvironmentVaria ble("Windir"))

Aproach 2
********
Dim winfolder As String =
CType(System.En vironment.GetFo lderPath(Enviro nment.SpecialFo lder.System).Sp l
it("\"), String())(0) + "\" +
CType(System.En vironment.GetFo lderPath(Enviro nment.SpecialFo lder.System).Sp l
it("\"), String())(1)

MsgBox(winfolde r)

Regards,
--
Angel J. Hernández M.
MCP - MCAD - MCSD - MCDBA
http://groups.msn.com/desarrolladoresmiranda
http://ajhsis.net
"Richard L Rosenheim" <ri*****@rlr.co m> escribió en el mensaje
news:OQ******** ******@tk2msftn gp13.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.Environm ent.SystemDirec tory. On my machine, it returns "C:\Windows\Sys tem32". What I'm looking for in this case is "C:\Windows ".

TIA,

Richard Rosenheim


Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5305
by: lucpustjens | last post by:
Hello, I want te determine the client operating system, because I need to kno the default cookie directory. If there is a way to determine the cooki directory directly, than it is also good. the used OS te determine are: win 95, win 98, win ME, win XP, win NT Thanks for help,
0
302
by: Buddy Ackerman | last post by:
I need to programatically determine the directory that the application/service is running from. If I use Environment.CurrentDirectory it returns the System32 directory. Is there anyway to get this the correct directory?
3
1908
by: Web Webon | last post by:
Hi everybody! I wonder if this is possible? I need to determine if a client is using "windows classic folders" or anything else. If I instantiate a Shell ActiveX object is there a way of obtaining this information from javascript? (I know that the user will get prompted about allowing such an operation, but I am willing to live with this). Because of the way one of my pages work, I need to know this information in order to "cover up"...
6
1350
by: dawn | last post by:
Hi, How can I determine the directory from which my app is started. Since upon installation the user can decide in which directory to install the file...I want to be able to load a file from a directory within that install directory no matter what it is. How best to deal with this? Tx.
0
943
by: marfi95 | last post by:
Basically, I keep the state of some objects serialized in an xml file through the use of a data set. The xml file serialized is persisted onto a shared network drive. However, the file is only deserialized upon startup. I'd like to automatically refresh the state of my objects when other users have changed their state through this same persisted file. What is the best way to determine when this has happened ? Continually run a timer...
3
6809
by: KSC | last post by:
Hello, Is there a way to programmatically determine if a directory is shared and if so, what the sharename is? It seems a simple question, but I have been searching and not found the answer... Thanks in advance!
12
1754
by: garyusenet | last post by:
I want to write a program that lists all folders on my local hard drive in order of size, any ideas for how I might do this? Thankyou, Gary.
1
2558
by: topramen | last post by:
does any one here know of a good way to to determine whether or not a given path is a directory (e.g., "c:\mydir") or a file (e.g., "c:\mydir \myfile.txt")? i started attacking this problem by using filesystemobject to check whether or not a directory existed for the path. if so, it was a directory path. if not, i checked to see if a file existed for it. if so, it was a file path. this code is shown below: ...
9
1909
by: Scott | last post by:
What is the most reliable method to determine the folder a script is running in? I was looking at the globals in $_SERVER but all the variables also listed the actual file the script was running in. Thanks Scotty
0
8486
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8404
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8680
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6238
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5705
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4418
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2819
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2063
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.