Retreive System Information with Environ

On Windows 2000/NT systems, the Environ$ function can be used to retreive certain information from the system, without using any API calls! For example, to retreive the location of the temp directory, use

Debug.Print Environ$("temp")

For the system directory, try

Environ$("windir") & IIf(Len(Environ$("OS")), "\SYSTEM32", "\SYSTEM")

Other environment variables are also available - to see them go to Start | Settings | Control Panel, open the System item, click the Advanced tab, and click the Environment Variables button.

Please note: Environment variables can vary from PC to PC, are user-modifiable, and other than standard items such as WinDir and Temp, Environ should not be entirely relied apon.

You might also like...

Comments

Mike G

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.” - Rick Osborne