Please let other users know how useful this tip is by rating it below. Do you have a tip or code of your own you'd like to share? Submit it here.
System.Environment namespace provides all the functionality to extract the environment information -- like UserName and OS version, for instance.
File GetEnvInfo.vb
Imports System
Class GetEnvInfo
Shared Sub main()
Console.WriteLine("")
Console.WriteLine("Logged On User")
Console.WriteLine(Environment.UserName)
Console.WriteLine("")
Console.WriteLine("Machine Name")
Console.WriteLine(Environment.MachineName)
Console.WriteLine("")
Console.WriteLine("OS version")
Console.WriteLine(Environment.OSVersion)
Console.WriteLine("")
Console.WriteLine("System Directory")
Console.WriteLine(Environment.SystemDirectory)
Console.WriteLine("")
Console.WriteLine("TMP Folder")
Console.WriteLine(Environment.GetEnvironmentVariable("TMP"))
Console.WriteLine("")
Console.WriteLine("Class Path")
Console.WriteLine(Environment.GetEnvironmentVariable("ClassPath"))
Console.WriteLine("")
End Sub
End Class
Compile the file as Vbc GetEnvInfo.vb. Execute GetEnvInfo.exe and see the results.
Source: DotNetExtreme.com
This was first published in August 2003