MyChat Scripts Engine: GetEnvValue
Function to obtain values of Windows environment variables.
You can get the list of all environment variables, when entering the "set" command in the console or in System Properties -> "Environment variables":
Syntax
function GetEnvValue(sVariable: string): string;
Parameters and return values
Parameter |
Type |
Value |
sVariable |
string |
name of an environment variable, which value you need to obtain. |
Function result
Text string. If you specify the nonexistent variable value, then an empty string returns.
Example
begin
mLogScript(GetEnvValue('COMPUTERNAME'), 'Name of local computer');
mLogScript(GetEnvValue('ComSpec'), 'Command interpreter');
mLogScript(GetEnvValue('HOMEDRIVE') + GetEnvValue('HOMEPATH'), 'Windows user home folder');
mLogScript(GetEnvValue('NUMBER_OF_PROCESSORS'), 'Processors count');
mLogScript(GetEnvValue('SystemRoot'), 'OS path');
end.
Script work result
[13:27:40] (Log "GetEnvValue"): [Name of local computer] TOSHIBA-PC
[13:27:40] (Log "GetEnvValue"): [Command interpreter] C:\windows\system32\cmd.exe
[13:27:40] (Log "GetEnvValue"): [Windows user home folder] C:\Users\Toshiba
[13:27:40] (Log "GetEnvValue"): [Processors count] 8
[13:27:40] (Log "GetEnvValue"): [OS path] C:\windows
[13:27:40] (Run "GetEnvValue"): Script operation time: 2 ms
[13:27:40] (Run "GetEnvValue"): Script done successfully.