|
Subject:
|
Enviromental Variables
|
|
Posted By:
|
Apocolypse2005
|
Post Date:
|
4/18/2008 4:12:41 PM
|
Howdy, What other environmental variables apart from "USERNAME" are there? Also how do you know about them?
This is mainly targetted at Brian Wren but feel free to answer.
Cheers
------------------------------------------------ Apocolypse2005 Always ready and waiting to be helped! Soon changing as I have got so much better as a programmer!
|
|
Reply By:
|
dparsons
|
Reply Date:
|
4/18/2008 4:21:37 PM
|
If i have understood you correctly, you are looking for the environement variables of both the system and the user? To view these right click on 'My Computer' go to properties, select the Advanced tab, then at the bottom of that tab press the Environment Variables button. (This is both user and system variables).
If memory serves me, you can access any of this by doing something like Environ("[variable]"), I could be wrong but I think thats what it is.
hth. -Doug
=========================================================== Read this if you want to know how to get a correct reply for your question: http://www.catb.org/~esr/faqs/smart-questions.html =========================================================== .: Wrox Technical Editor / Author :. Wrox Books 24 x 7 ===========================================================
|
|
Reply By:
|
BrianWren
|
Reply Date:
|
4/18/2008 5:07:08 PM
|
It would be easier to answer if you could give an idea of what brings this question to mind, or what it is that you want to do.
|
|
Reply By:
|
Apocolypse2005
|
Reply Date:
|
4/20/2008 2:38:39 PM
|
Well Mr Wren, this is needed for when your rooting through someones file structure. So when i need to know whether some one has a my music or what drive they have there my documents on.
|
|
Reply By:
|
BrianWren
|
Reply Date:
|
4/21/2008 12:47:25 PM
|
I don't think your understanding is right (or mine isn't...).
When I look on my machine, MyDocuments (no space in the name) is under DocumentsAndSettings\<my logon>
So once you have thier logon, the rest is the same for everyone.
If you can specify an alternate location for these files (MyMusic is under MyDocuments), I'm unaware of that.
I'm not sure how to get the full list of environment variables. I’m sure you can, because typing C:\>SET at a DOS prompt will list them all. That means that the OS is willing to comply, if you can find the API to ask correctly...
|
|
Reply By:
|
BrianWren
|
Reply Date:
|
4/22/2008 11:58:40 AM
|
But to answer the specifics you asked...
Use Environ(). There are 2 ways to use Environ(). If you pass the name of an environment variable Environ() returns the value of that variable, or a blank string if the variable is not defined. If you pass a number, Environ() returns the entire environment string (the variable name, the equal sign and the value) of the variable at the specified position. If there is no variable at the spec’d pos., Environ() returns a blank string.Private Sub SomeSub()
Dim EnvSet As String ' "Set" because it returns the name/val set.
Dim idx As Integer
idx = 1
Do
EnvSet = Environ(idx)
Debug.Print EnvSet
idx = idx + 1
Loop Until EnvSet = ""
End Sub
|
|
Reply By:
|
Apocolypse2005
|
Reply Date:
|
4/23/2008 4:23:52 PM
|
So this could find out all the environment variables? That c:\> set works a treat, you can get shed loads of information about the computer, thats what I was looking for, Cheers Brian (thats why they call you a senior member ;) )
|
|
Reply By:
|
BrianWren
|
Reply Date:
|
4/25/2008 4:32:34 PM
|
Actually, they call me a Senior Member because I haunt this place, and can't keep my mouth shut...
|