Using Environ
Many people ask how to get certain system information and environ is the solution.
Environ is a command that allows you to get system environmental information.
It can also get any of the Environment Variables from the [System Properties, Advanced, Environment Variables] settings in windows.
Original Author: Zinna Pro
Code
Using Environ Syntax: Environ(expression) Where expression is includes the environmental variable you wish to Example: Call MsgBox("Your Temp Directory is: " & Environ("Temp"), List of Common Expressions and sample output: Full List of variables my computer can get: Code used to get all variables: Dim environinfo as string 'Declare environinfo
information.
Properties, Advanced, Environment Variables] settings in windows.
retrieve
vbInformation, "Temp Directory Finder")
Expression
What came from my computer
ALLUSERSPROFILE
H:Documents and SettingsAll Users
APPDATA
H:Documents and SettingsinnaProApplication
Data
CLIENTNAME
Console
CommonProgramFiles
H:Program FilesCommon Files
COMPUTERNAME
LOCALHOST
ComSpec
H:WINDOWSsystem32cmd.exe
HOMEDRIVE
H:
HOMEPATH
Documents and SettingsinnaPro
LOGONSERVER
\LOCALHOST
NUMBER_OF_PROCESSORS
1
OS
Windows_NT
Path
H:WINDOWSsystem32;H:WINDOWS;H:WINDOWSSystem32Wbem
PATHEXT
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
PROCESSOR_ARCHITECTURE
x86
PROCESSOR_IDENTIFIER
x86 Family 6 Model 6 Stepping 2, AuthenticAMD
PROCESSOR_LEVEL
6
PROCESSOR_REVISION
0602
ProgramFiles
H:Program Files
SystemDrive
H:
SystemRoot
H:WINDOWS
TEMP
H:DOCUME~1innaProLOCALS~1Temp
TMP
H:DOCUME~1innaProLOCALS~1Temp
USERDOMAIN
LOCALHOST
USERNAME
ZinnaPro
USERPROFILE
H:Documents and SettingsinnaPro
windir
H:WINDOWS
variable as string
On Error goto done 'If an error occurs then goto
end (error expected due to large for loop)
environinfo = "" 'Set our variable to nothing
For i = 1 To 200 'Do a large for loop and try 200
environmental indexes augmenting i by 1
environinfo = environinfo & Environ(i) & vbCrLf
'Augment variable and add put on separate lines
Next i 'Loop until i is 200
done: 'Where to go on error, means we are done in this
case
clipboard.settext environinfo 'Copy our variable
information to clipboard
Call MsgBox("Your Environment Variables have been copied to clipboard",
vbInformation, "Environs Found") 'alert the user that
the variables are in clipboard
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.