Question - What are the ways in UFT to get system environment variables in UFT?
Answer -
There are three ways to get system environment variables in UFT
Use the WSH shell object
Use WMI’s Win32_Environment Class
Read variables from the registry
Set myShell = CreateObject (“WScript.Shell”)
WScript.Echo myShell.ExpandEnvironmentStrings( "%PATHEXT%" )
myShell=Nothing,
The output will be .BAT;.CMD;.VBS;. VBE;. JS;. JSE
Other user variable, like TEMP, overwrite their system counterpart
Set myShell = CreateObject( "WScript.Shell" )
WScript.Echo myShell.ExpandEnvironmentStrings( "TEMP=%TEMP%" )
myShell=Nothing
The output will be
TEMP:C:\DOCUME~1\You\LOCALS~1\Temp